Jump to content

net.lua2json has a HUGE problem ("lexical error: invalid char in JSON'


Recommended Posts

Posted

If you are using lua2json with a Lua table that contains a number value set to math.huge, that value is (incorrectly) converted to 'inf' in the resulting JSON.

Should you then try to load this value from the resulting JSON text file (a number with value of 'inf'), net.json2lua throws a tremendously unhelpful error:

image.png 

So be advised, it's NOT an invalid char at all - it's the (incorrect) 'inf' value that is passed for a number that held the value math.huge.

So if you are scripting for persistence, make sure that you filter all 'inf' and replace them with large numbers before you convert to JSON.

  • Like 2
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...