Jump to content

Need a JSON library implemented in C language

Recommended Posts

Recently, the new update made us able to rename a beefalo.

When I renamed a beefalo as "Jupiter's Beefalo" tried to use "json.encode(beefalo:GetSaveRecord())" to get the string form of saving record, the string was like ".......Jupiter\'s Beefalo......", which seemed ok in lua enviroment in DST.

However, when I tried to use this string in Python, I executed "json.loads(the_string)" and it went wrong because of the damn "\'s" in the string.

The problem was caused by the mechanism that the JSON library of lua would change "'" into "\'" when encoding a string.

Some may say that I can choose "json.encode_compatible()" function instead.

But the note of DST official "json.lua" warned that we should never add decode support from encode_compliant's returned string.

Since I wanted to encode data and send it to my backend server, and retrieved it and decode it to be used in game, I desperately need a JSON library implemented in C language to make it happen.

Will that be possible?

Link to comment
Share on other sites

Klei uses json4Lua to convert between lua tables and json strings in DST.

This library has many fatal flaws, which are presented on http://lua-users.org/wiki/JsonModules.

I think you can use other json libraries implemented in pure lua to replace it if necessary.

The alternatives I found are as follows.

  1.  LunaJson https://github.com/grafi-tt/lunajson
  2.  json.lua https://github.com/rxi/json.lua
Link to comment
Share on other sites

Fun fact is, if you go to Careers page, you will see the only job Klei is hiring for right now is a C++ programmer! (The person getting hired will probably know all C languages, due to background requirement.)

I'm sure they are aware of this problems and will fix it. :)

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

  • Create New...