Live data from Hacker News

FracturedJson

github.com

31–40 of 173 posts

Re: FracturedJson

#31
post #8

Earlier quoted context omitted.

Unrelated: why spaces inside the parentheses? It’s not the first time I see this, but this is incorrect!

JSON doesn't have parentheses, but it does have braces and brackets. The JSON spec specifically allows spaces. > Insignificant whitespace is allowed before or after any token.

I was talking about the parent comment, which has spaces inside the parenthesis (I do prefer no spaces inside brackets and braces in my JSONs, but that’s another story).

Re: FracturedJson

#32

Great. Now integrate this into every JSON library and tool so I get to see it's output more often

I think integration into jq would be both powerful and sufficient.

Powerful but not sufficient. There’s plenty of us who don’t use jq for various reasons.

Re: FracturedJson

#33

Earlier quoted context omitted.

Yaml is the worst. Humans and LLMs alike get it wrong. I used to laugh at XML but Yaml made me look at XML wistfully. Yaml - just say Norway

The Norway issue is a bit blown out of proportion seeing as the country should really be a string `"no"` rather than the `no` value

Yeah, but it's a fun slogan. My real peeve is constantly getting the spaces wrong and no tooling to compensete for its warts. If there were linters and test frameworks and unit tests etc for yaml, I'd just sigh and move on. But current situation is, for instance in ADO Yaml: "So it's time to cut a release and time is short - we have a surprise for you! This will make some condition go true which triggers something not tested up till now, you will now randomly commit shit on the release branch until it builds again."

Stuff that would have been structurally impossible in XML will happen in yaml. And I don't even like XML.

Re: FracturedJson

#34
post #6

Nice. And BTW, thanks for supporting comments - the reason given for keeping comments out of standard Json is silly ( "they would be used for parsing directives" ).

It's a pretty sensible policy, really. Corollary to Hyrum's Law - do not permit your API to have any behaviours, useful or otherwise, which someone might depend on but which aren't part of your design goals. For programmers in particular, who are sodding munchkins and cannot be trusted not to do something clever but unintended just because it solves a problem for them, that means aggressively hamstringing everything.…

JSON is used as config files and static resources all the time. These type of files really need comments. Preventing comments in JSON is punishing the wide majority to prevent a small minority from doing something stupid. But stupid gonna stupid, it's just condescending from Mister JSON to think he can do anything about it.

Re: FracturedJson

#35
post #17

It looks like there are two maintained implementations of this at the moment - one in C# https://github.com/j-brooke/FracturedJson/wiki/.NET-Library and another in TypeScript/JavaScript https://github.com/j-brooke/FracturedJsonJs . They each have their own test suite. There's an older pure Python version but it's no longer maintained - the author of that recently replaced it with a Python library wrapping the C# code…

This is a good idea, though I don’t think it would guarantee program equivalence beyond the test cases.

Re: FracturedJson

#36
post #27

Earlier quoted context omitted.

We stopped having this problem over ten years ago when spec 1.1 was implemented. Why are people still harking on about it?

Now add brackets and end-tags, I'll reconsider. ;)

Brackets works fine:

    Roles: [editor, product_manager]
End tags, that I’m not sure what that is. But three dashes is part of the spec to delineate sections:

    something:
        setting: true
    ---
    another:
        thing: false

Re: FracturedJson

#37

While I wish JSON formally supported comments, it seems more sensible (compatible) to just nest them inside of a keyed list or object as strings. { foo: "bar", ans: 42, comments: { ans: "Douglas Adams" } }

Works right up until you get an entity where the field `comments` is suddenly relevant and then you need to go change everything everywhere. Much better to use the right tool for the job, if you want JSONC, be explicit and use JSONC.

Re: FracturedJson

#38
These JSON files are actually readable, congrats. I’m wondering whether this could be handled via an additional attached file instead. For example, I could have mycomplexdata.json and an accompanying mycomplexdata.jsonfranc. When the file is opened in the IDE, the IDE would merge the two automatically.

That way, the original JSON file stays clean and isn’t polluted with extra data.

Re: FracturedJson

#39
post #27

Earlier quoted context omitted.

This is a reference to YAML parsing the two letter ISO country code for Norway: country: no As equivalent to a boolean falsy value: country: false It is a relatively common source of problems. One solution is to escape the value: country: “no” More context: https://www.bram.us/2022/01/11/yaml-the-norway-problem/

We stopped having this problem over ten years ago when spec 1.1 was implemented. Why are people still harking on about it?

Because there's a metric ton of software out there that was built once upon a time and then that bit was never updated. I've seen this issue out in the wild across more industries than I can count.

Re: FracturedJson

#40
I tokenized these and they seem to use around 20% less tokens than the original JSONs. Which makes me think a schema like this might optimize latency and costs in constrained LLM decoding.

I know that LLMs are very familiar with JSON, and choosing uncommon schemas just to reduce tokens hurts semantic performance. But a schema that is sufficiently JSON-like probably won't disrupt model path/patterns that much and prevent unintended bias.

Post reply on HN