Not a bug
BYOND Version:513
Operating System:Windows 10 Home 64-bit
Web Browser:Chrome 84.0.4147.89
Applies to:Dream Daemon
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:

json_encode() can set values to null if the table runs too deep. It seems based on the general size of the list it's trying to parse, I think. I discovered this issue when trying to save items inside a pill container that was inside a medical kit that was inside a backpack that was inside a torso that was inside a mob. The code runs fine and the debug message logs that it sent that data to the list, but it doesn't seem to want to save in the list.

Numbered Steps to Reproduce Problem:
Make a large JSON table.
JSON Encode it.
Cry as it loses important data.

Code Snippet (if applicable) to Reproduce Problem:

. = list()

.["list0"] = nest_list(50)

var/encoded_list = json_encode(.)

world.log << "Saved?"


world.log << "Running: nest_list([value])."

. = list()

if(value <= 0)
.["final value"] = 1234
.["list[value]"] = nest_list(value - 1)

return .

Expected Results:
It will produce a table that is 50 nests deep, and sets the key and value to null.

Actual Results:
It gives up halfway through and only produces a list that isn't that deep.

{"list0":{"list50":{"list49":{"list48":{"list47":{"list46":{"l ist45":{"list44":{"list43":{"list42":{"list41":{"list40":{"l ist39":{"list38":{"list37":{"list36":{"list35":{"list34":{"l ist33":{null:null}}}}}}}}}}}}}}}}}}}}

Does the problem occur:
Every time? Or how often? Every time.
In other games? Yes.
In other user accounts? Unknown.
On other computers? Unknown.

When does the problem NOT occur?
I mean, the only time it doesn't occur is if you don't use large lists.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked?
Tested the last few versions and they all had the same issue.

None that I know of.

Lummox JR resolved issue (Not a bug)
This is intentional behavior. There has to be an upper limit on how deep the lists can nest, because the function that handles this is recursive. I'm willing to consider raising the upper limit but not too high. To be honest I'm amazed you were able to hit the limit in real code.

Also, this is not a Dream Maker issue, but Dream Daemon. Issues that apply to Dream Maker would involve compiler stuff, whereas this is clearly a matter of server behavior.
Please document the limit in the reference
I believe the limit is 18 for those who are curious.

Login to reply.