x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Json deserializing finds weird first char

When the JsonReader executes JsonReader::ReadStart(...) and tries to find the next token with JsonReader::NextToken(...), then the outcome of this

             CharType Char;
             Stream->Serialize(&Char, sizeof(CharType));

is this: alt text

Obviously, it should be '{'.

This is the json I'm using (taken from http://json.org/example.html ):

 {
     "glossary": {
         "title": "example glossary",
         "GlossDiv": {
             "title": "S",
             "GlossList": {
                 "GlossEntry": {
                     "ID": "SGML",
                     "SortAs": "SGML",
                     "GlossTerm": "Standard Generalized Markup Language",
                     "Acronym": "SGML",
                     "Abbrev": "ISO 8879:1986",
                     "GlossDef": {
                         "para": "A meta-markup language, used to create markup languages such as DocBook.”,
                         "GlossSeeAlso": ["GML", "XML"]
                     },
                     "GlossSee": "markup"
                 }
             }
         }
     }
 }

And this the code:

 FArchive* SaveFile = IFileManager::Get().CreateFileReader(*FPaths::GameConfigDir().Append(FString("data2.json")));
     if (SaveFile)
     {
 
         TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
         TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(SaveFile);
 
         UE_LOG(LogEngine, Error, TEXT("JSONERROR: %s"), *JsonReader->GetErrorMessage());
 
         const bool ds = FJsonSerializer::Deserialize(JsonReader, JsonObject);

I'm on OSX. Encoding: file -I gave me us-ascii first. I added an ä and saved which resulted in it being utf-8. Still the same weird character being read.

Any ideas? : /

Product Version: UE 4.9
Tags:
more ▼

asked Sep 29 '15 at 03:17 PM in C++ Programming

avatar image

Timoses
91 14 14 22

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

As always I find the answer just after posting:

It shouldn't be

 TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(SaveFile);

But

 TSharedRef<TJsonReader<UTF8CHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(SaveFile);

works.

more ▼

answered Sep 29 '15 at 04:08 PM

avatar image

Timoses
91 14 14 22

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question