[1.1.77] Data raw dump contains invalid JSON

This subforum contains all the issues which we already resolved.
Post Reply
ilbJanissary
Inserter
Inserter
Posts: 33
Joined: Tue May 28, 2019 12:34 pm
Contact:

[1.1.77] Data raw dump contains invalid JSON

Post by ilbJanissary »

When exporting data using the new --dump-data flag, the resulting JSON is invalid. There are multiple properties like:

`"literal_value": inf`

Since `inf` is not quoted, it is invalid JSON and the file cannot be parsed.

ilbJanissary
Inserter
Inserter
Posts: 33
Joined: Tue May 28, 2019 12:34 pm
Contact:

Re: [1.1.77] Data raw dump contains invalid JSON

Post by ilbJanissary »

Assuming these represent positive / negative infinity, there doesn't seem to be a supported way to represent those in JSON. I would personally find `null`, or`"inf"/"-inf"`, or `"Infinity" / "-Infinity"` acceptable (as long as those strings are quoted in order to be valid JSON).

ilbJanissary
Inserter
Inserter
Posts: 33
Joined: Tue May 28, 2019 12:34 pm
Contact:

Re: [1.1.77] Data raw dump contains invalid JSON

Post by ilbJanissary »

Bilka pointed out that the new 'dump data raw' dumps using the format our parser can handle which includes inf/nan. Looking online it seems it's not an uncommon issue other people have run into across multiple other languages/parsers.
I glossed over this comment from Rseding91 in Discord on 1/28/23 at the time but I think this describes the exact issue.

Generally I would say if JavaScript can't parse your JavaScript Object Notation you've got a problem, but if this is known and can't be resolved easily, I can always run a dirty little regex against it before I try to parse it.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.77] Data raw dump contains invalid JSON

Post by Rseding91 »

I've changed it for the next release so it will write infinite as "inf" and "-inf".
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Resolved Problems and Bugs”