You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Better support for SAX style serialize and deserialize in new version? #554
if i want to use this to create a json serializer and deserializer for other language like lua.
in lua to serialize a lua table to string , i need to do iterate lua table to create a temp cpp json object first, then use it's dump() method to string.
rapidjson give a rapidjson::Writer class . with this we can serialize a lua table to string directly in iterating lua table.
The link is dead. I still don't understand your use case.
You want to iterate over a Lua table and create a JSON serialization from it? But you want to do this without creating an internal JSON representation from the Lua table?
You can convert arbitrary types from/to json with the techniques described in https://github.com/nlohmann/json#arbitrary-types-conversions. But if I understand you correctly, you do not want to create a json object, but directly a JSON compliant string representation from you Lua array, right?
alright , the rapidjson given rapidjson::Reader and rapidjson::Writer could do this .
cos i like this library so i want to do it use this . if couldn't i'll give up .
thanks!
I do not understand how exactly my library could help you. We provide a C++-style API for JSON values, support to create these values from arbitrary types, and also the possibility to serialize them. But it seems that you need a translation from Lua types to JSON string. This can be implemented manually without the need of any third-party library.
And why exactly don't you want to create an temporary object in the first place? Performance?
Activity
nlohmann commentedon Apr 15, 2017
Can you be more specific?
salutant commentedon Apr 15, 2017
if i want to use this to create a json serializer and deserializer for other language like lua.
in lua to serialize a lua table to string , i need to do iterate lua table to create a temp cpp json object first, then use it's dump() method to string.
rapidjson give a
rapidjson::Writerclass . with this we can serialize a lua table to string directly in iterating lua table.https://github.com/xpol/lua-rapidjson this project create a lua json serializer and deserializer use rapidjson maybe can help you .
nlohmann commentedon Apr 15, 2017
The link is dead. I still don't understand your use case.
You want to iterate over a Lua table and create a JSON serialization from it? But you want to do this without creating an internal JSON representation from the Lua table?
salutant commentedon Apr 15, 2017
sorry , the link is okay now,
i want to explain my idea clearly, but i think i couldn't, so i write some code
this code can serialize a lua table to json string , i want json.hpp can do something like this .
nlohmann commentedon Apr 15, 2017
You can convert arbitrary types from/to
jsonwith the techniques described in https://github.com/nlohmann/json#arbitrary-types-conversions. But if I understand you correctly, you do not want to create ajsonobject, but directly a JSON compliant string representation from you Lua array, right?salutant commentedon Apr 15, 2017
yes i don't want to create json object
nlohmann commentedon Apr 15, 2017
But how would this library help you if you do not want to use any of its functions?
salutant commentedon Apr 15, 2017
alright , the rapidjson given
rapidjson::Readerandrapidjson::Writercould do this .cos i like this library so i want to do it use this . if couldn't i'll give up .
thanks!
nlohmann commentedon Apr 15, 2017
I do not understand how exactly my library could help you. We provide a C++-style API for JSON values, support to create these values from arbitrary types, and also the possibility to serialize them. But it seems that you need a translation from Lua types to JSON string. This can be implemented manually without the need of any third-party library.
And why exactly don't you want to create an temporary object in the first place? Performance?
nlohmann commentedon Feb 13, 2018
FYI: #971