This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
SquidDev's profile picture

[CC1.73][SSP] textutils.serializeJSON broken for DataTags

Started by SquidDev, 07 March 2015 - 04:16 PM
SquidDev #1
Posted 07 March 2015 - 05:16 PM
Trying to run commands such as /give @p CommandComputer:pocket_computer 1 1 {computerId:1} using a lua table of {computerId=1} produces JSON of {"computerId":1}. This results in the NBT data being stored as "computerId" rather than computerId.

On line 278 of textutils.serializeJSONImpl I think that


return string.format( "%q", t )

should be something like:


local sResult = string.format("%q", t)
if sResult == '"' .. t .. '"' then
  return t
end
return sResult
Edited on 07 March 2015 - 04:16 PM
dan200 #2
Posted 12 March 2015 - 09:49 AM
Are you sure that's right? I implemented the function using the spec on JSON.org
SquidDev #3
Posted 12 March 2015 - 09:58 AM
Are you sure that's right? I implemented the function using the spec on JSON.org

It does follow the spec but Minecraft uses this option on the JSON parser which seems to result in the names of tags being corrupted. I'll do some more testing tonight.