Just watched this clip:
Just wondering how much impact it will have here.
Just another specialist text-based data structure. JSON remains super convenient in JavaScript and other programming environments, convert to TOON (shesh! What a painful name!) if needed when passing to an LLM (in the future when it is actually properly supported - if that ever happens). Or use CSV, ...
Why did they come up with it ? Because AI cost them too much in token usage as JSON is larger.
For the rest it is not very useful and JSON will not go anywhere I think.
JSON is great. If only they did not make this stupid, deliberate decision not to enable comments in the data structure (like in XML). And yes, I am aware of the option to set comments in textual fields which should be ignored by the consumer.
+1 on the comments issue.
Yet another one...
Which reminds me of xkcd: Standards
As for comments... I mostly use YAML for config stuff, you can have comments and other nice features like anchors for reusability.
And since it's a superset of JSON, you can use JSON in YAML documents as well ![]()
It is a wet Saturday morning.... so hey - node-red-node-toon (node) - Node-RED
I was just about to look to see if anyone had built a Toon converter node.
I was thinking about json yesterday. Didn't know about TOON. But I have slowly grown to prefer javascript objects. And it seems like when I searched for the topic, some people didn't even understand the point of it. Perhaps this can make it clear:
JSON:
{
"users": [
{"id": 1, "name": "A", "role": "Admin"},
{"id": 2, "name": "B", "role": "User"},
{"id": 3, "name": "C", "role": "User"}
}
JS Object:
{
users: [
{id: 1, name: "A", role: "Admin"},
{id: 2, name: "B", role: "User"}, // can have comments
{id: 3, name: "C", role: "User"}, // optional trailing comma
}
Looks way cleaner to me! Perhaps a lot of people don't work with json directly (but parse it directly into their preferred language instead). Perhaps using jsonc to support comments (it is nice, but rarely supported. Don't think NR has any easy way to import it?). Perhaps there are loopholes to this. One argument I heard was that JSON can be used by all languages, not just js. But if JSON can be used, then there is no hard limitation that prevents js object to be used also. I'm perfectly happy about having limitations like no functions, no funky var names etc. I'd love to be able to parse such a js object from file in NR, but I don't think that's possible either.
Umm, looks like your JS Object is missing a closing ]
JS objects are supposed to be used in code execution, not for transferring data. They can include properties not supported by JSON (e.g. functions) hence JSON<->JS conversion is not fully bidirectional, and imposes a risk of code injection. But if you restrict the object to data properties only, then it's a nice idea, which I like.
Note that JSON is always a string. It is a string representation of a javascript object. It stands for Javascript Object Notation.
This post and this post should help to clarify the difference between Javascript objects and JSON.
And the JSON example is also missing a closing ] bracket.
Should be...
{
"users": [
{ "id": 1, "name": "A", "role": "Admin" },
{ "id": 2, "name": "B", "role": "User" },
{ "id": 3, "name": "C", "role": "User" }
]
}
I don't understand what you mean by that. Where do you mean that you could use either? JS objects can only be used in JS. JSON strings can be used anywhere.
In a function node you can do JSON.parse(someStringVariable) to convert JSON to JS object.
Keep in mind that the TOON format is only meant to be used with AI to reduce the number of used tokens, ie: Token-Oriented Object Notation
Token-Oriented Object Notation is a compact, human-readable encoding of the JSON data model that minimizes tokens and makes structure easy for models to follow. It's intended for LLM input as a drop-in, lossless representation of your existing JSON.
Totally agree! Trailing comma's is another bug-bear of mine. I'm constantly caught out by that one.
And that's the point isn't it. You can code a JavaScript object as JSON and it will work as expected. The difference only really matters once you want to move that data out of native JavaScript.
Seems I really poked a touchy subject.
But it is interesting to see people's reactions.
I hadn't noticed any touchiness.
I'd say passionate rather than touchy.
Its who and what we we are. ![]()
I failed English. ![]()
You are right. It was the wrong word, but the best at the time.