Disclaimer: All rights reserved.
Reprint must indicate source:http://blog.csdn.net/cartzhang/article/details/41009343
UE4 JSON parsing blog address:http://blog.csdn.net/cartzhang/article/details/43794409
UE4 JSON read-write < two >
UE4 JSON read-write method
JSON parsing has a lot of open source libraries.
UE4 JSON is used in the public->serialization of the code.
Header files include: Json.h
The read-write creation of JSON is a singleton pattern of static formation. There are jsonwrite or Jsonreader factory to create it.
To read as a sample:
Read the code:
float _score = Myplayerstate->getscore (); Fstring _player_name = Myplayerstate->getname (); int _kills = Myplayerstate->getkills (); int _deaths = Myplayerstate->getdeaths (); Fstring Jsonstr; tsharedref< Tjsonwriter<tchar, tcondensedjsonprintpolicy<tchar> > > jsonwriter = TJsonWriterFactory <tchar, tcondensedjsonprintpolicy<tchar> >::create (&JSONSTR); Jsonwriter->writeobjectstart (); Jsonwriter->writevalue (TEXT ("name"), _player_name); Jsonwriter->writevalue (TEXT ("Score"), _score); Jsonwriter->writevalue (TEXT ("deaths"), _deaths); Jsonwriter->writevalue (TEXT ("Kills"), _kills) <span style= "White-space:pre" ></span>jsonwriter- >writeobjectend ();//Close The writer and finalize the output such that jsonstr have what we wantjsonwriter->close (); return jsonstr;
The Write object can be an array of objcet or arrays, value.
A process of reading and writing. Start and end should be appropriate due to the JSON format requirements. How else would I know where an object or an array ends?
This can cause confusion.
All reads and writes are completed after close.
Look at the online sample very little, oneself affixed a, oneself also convenient!
----------------------------
If you have any questions, please feel free to contact us!
Thank you very much.
UE4 JSON read-write < a >