Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pmuellr/sloppy_json_parse
a parser for a sloppier kind of JSON
https://github.com/pmuellr/sloppy_json_parse
Last synced: about 2 months ago
JSON representation
a parser for a sloppier kind of JSON
- Host: GitHub
- URL: https://github.com/pmuellr/sloppy_json_parse
- Owner: pmuellr
- Created: 2010-08-03T21:43:39.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2010-08-03T22:02:36.000Z (over 14 years ago)
- Last Synced: 2024-04-09T21:04:47.758Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 93.8 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
`sloppy_json_parse` - a parser for a sloppier kind of JSON
========================================================The function `sloppy_json_parse()` is a fork of the `json_parse()` function
available at
[http://www.json.org/json_parse.js](http://www.json.org/json_parse.js). The
API for the two functions is the same, besides the format of the text that
they parse.`sloppy_json_parse()` parses a language similar to JSON, but with these
differences:* commas are optional
* comments start with the '#' character and end with the end of the line
* strings which match the regex `/[$_A-Z][$\w]*/i` don't need to be quoted,
except that the strings "null", "true", and "false" must always be quoted.
The regex is the syntax of JavaScript identifiers.Re-inspired by [CoffeeScript](http://jashkenas.github.com/coffee-script/#objects_and_arrays)
after [thinking about it](http://pmuellr.blogspot.com/2008/08/better-than-json.html)
[for a short while](http://pmuellr.blogspot.com/2007/03/json-array-vulnerability.html).examples
------------
### sloppy JSON ###
[1 2 3 dogs cats]### equivalent JSON ###
[1, 2, 3, "dogs", "cats"]----
### sloppy JSON ###
{x:y z:a}### equivalent JSON ###
{"x":"y", "z":"a"}----
### sloppy JSON ###
{
# some properties of the object
a: z # z is a string!
b: y # so is y
c: [1 2 3]
d: [ # d is an array
{
abc: true
def: false
} # end of this inner object
{
xyz: null
uvw: [101 202 303] # weird numbers
}
[4 5 6] # last element
]
# end of the properties
}### equivalent JSON ###
{
"a": "z",
"b": "y",
"c": [1, 2, 3],
"d": [
{
"abc": true,
"def": false
},
{
"xyz": null,
"uvw": [101, 202, 303]
},
[4, 5, 6]
]
}