Anuken/Arc

Wrong Parsing Unquoted strings in HJson

Zelaux opened this issue · 8 comments

Zelaux commented

I used this when writing HJson Support for Intellij idea
and I found some tricky cases which are parsed counterintuitively

Cases thats parsed in wrong way:

    • Given HJson
    it: it,
    value: value,
    
    • Expected Json
    {"it": "it,", "value": "value,"}
    • Actual Json
    {"it": "it", "value": "value"}

    • Given HJson
    [
    1, 2,
    O, T,
    3, 4,
    T, F
    ]
    
    • Expected Json
    [1, 2, "O, T,", 3, 4, "T, F"]
    • Actual Json
    [1,2,"O","T",3,4,"T","F"]
Anuken commented

This is not counterintuitive; why on earth would you expect the trailing comma to be part of the parsed string?! I intentionally made this change so modders wouldn't mess up when using unquoted strings. I don't care about the official spec - including commas (or, frankly, using unquoted strings at all) is a horrible idea.

Zelaux commented

I meant that the behavior described in the official spec is a little bit counterintuitive

Anuken commented

Right, but my parser doesn't have that behavior, so what is the issue with Arc...?

Zelaux commented

if you try to parse

key: very, very, very, long value

You got pasing exeption.
And also if someone try to search information how to write on hjson, he will find this

Anuken commented

key: very, very, very, long value

Why do this? I don't see why one would do that in a mindustry mod.

And also if someone try to search information how to write on hjson, he will find this

What's your point?

Zelaux commented

Why do this? I don't see why one would do that in a mindustry mod.

Example

description: Yes, this is my first mod, but it will be wonderful!!!

What's your point?

image

Anuken commented

Example

image

Result: {"description":"Yes, this is my first mod, but it will be wonderful!!!"}

What's your point?

That's not a point, that's an image. What are you trying to say?

Zelaux commented

Result: ....

I apologize in that case, further discussion is pointless