JSON5 is a proposed extension to JSON that brings ES5 enhancements to its syntax. It remains a strict subset of JavaScript, adds no new data types, and is a strict superset of existing JSON. - json5
Json5 basically adds support for comments, un-quoted keys, and trailing comas. In addition to:
I'm not saying that by default it should just be parsed, but if a option to the parser/deserializer could be provided that allowed these features, that would be really awesome :).
And given that it's a strict superset of existing JSON, this should not break anything, even if people were to run with the new flag turned on for old JSON files.
After reading through most of your feature-list on http://james.newtonking.com/json, it would seem that a lot of the requested features are already present in Newtonsoft.Json. What you already support are (according to your own list):
I think the only things to do are:
I've thought about this and if JSON5 catches on as a thing I'll do more to support it then.
@JamesNK What's you stance on this now, two years later?
Especially supporting comments make documenting JSON files alot easier.
JSON5 hasn't caught on as a thing.
I already support comments.
Oh, I did not know that. It's not that easy to find actually.
Thanks.
I'm not sure how we're measuring "catching on as a thing" (legitimate question), but I just noticed that the json5 node package was downloaded 3.5 million times this week. The trend shows steady progress since the last comment here in December of 2016:
Trend: http://www.npmtrends.com/json5
Looks like it'll be 4.5M downloads per week soon.
stats:
https://gist.github.com/anvaka/8e8fa57c7ee1350e3491
Might be nice to have it as a check-mark item.
Pretty sure it's caught on as a thing!
@JamesNK Came here to say it's definitely caught on as a thing! We're working on a project in Unity where there's different configuration files, and JSON5 is about the closest thing you can get to an actual object's representation in memory:
{
VehicleInfo : {
Name : 'Big Truck',
Colors : [
'Rusted Out',
],
Flags : 0x7, // is_player | is_unlockable | is_heavy
TopSpeed : 89.9,
Horsepower : 457.925, // leave this alone, jeff!!
Mass : 12500.0,
}
}
As you would imagine, VehicleInfo would be a class containing those particular members with easy to deduce types.
I actually wrote another data storage format for exactly this purpose, which looks like this:
VehicleInfo : {
Name = "Big Truck"
// 'Colors' is a string list, so we use a string tuple instead of a generic array
Colors = (
"Rusted Out",
)
Flags = 0x7 // is_player | is_unlockable | is_heavy
TopSpeed = 89.9f
Horsepower = 457.925f // leave this alone, jeff!!
Mass = 12500.0f
}
While serialization wasn't originally planned, it somehow ended up turning into a C-like JSON format...and the code is a mess and just doesn't make sense.
Instead of reinventing the wheel, JSON5 perfectly aligns with our needs. I see JSON used _everywhere_ these days, and I'm sure a lot of people would happily use JSON5 without needing to download a different library, and needing only to make very few code changes to support it.
Tldr;
JSON5 is amazing for game developers, please consider adding support!
Most helpful comment
I'm not sure how we're measuring "catching on as a thing" (legitimate question), but I just noticed that the json5 node package was downloaded 3.5 million times this week. The trend shows steady progress since the last comment here in December of 2016:
Trend: http://www.npmtrends.com/json5
Looks like it'll be 4.5M downloads per week soon.
stats:
https://gist.github.com/anvaka/8e8fa57c7ee1350e3491
Might be nice to have it as a check-mark item.