Comments (3)
but I found that the root of JSON parsed by mm_json.h must be object type.
I looked it up and as far as I know JSON root nodes are only allowed to be either an object or an array. I then check it and added some addition test and as far as I can tell both work fine. Could you point me to an example that did not work so I can check what went wrong.
When parsing an invalid JSON ["Extra close"]] the parser seems go into dead-loop
This is taken from my documentation at the top of the header:
It is important to note that while every valid JSON tree should be parsable
without problems, there is no guarantee that any invalid input is detected as
such, since the parser has only minimal validation.
I know this is probably not a perfect situation but the internal simplicity of the state machine has complex consequences for content validation. So in your given case ["Extra close"]]
the object ends with the first ]
since the array is now complete. I tested the exact example you gave me and I don't get a dead-loop. So I probably have to ask you for some code to check what API you use and how you use it.
P.S. How to get number of key-value pairs at the root?
Currently do not have a way. I don't have much time right now but I can check later if there is a way to add it.
from lib.
In the older RFC4267, root value of JSON must be object or array. But this is relaxed in RFC7159 and ECMA-404, such that any types can be the root. However, It seems the current design of MMX mm_json.h does not store the root value in tokens, so it can not differentiate between object or array anyway.
I have submitted my current integration in this branch. During the conformance tests, when it parses some invalid JSONs it goes to dead loop. You may check the test code. To make the build easier, you can delete all files in /src/tests/
except rapidjsontest.cpp
and mmxtest.cpp
, then run make
in the project root.
By the way, I have just added another token-based parser jsmn, which stores the root value as the first token. You may also refer to its test code.
from lib.
I am sick of it. I will remove the library. Do your benchmark without it. I don't care about all these standards and the expectation that come with it. If I wanted to have something like jsmn than I would have create something along side of or used it directly. Probably for the best so there is one less shitty json parser in this world.
from lib.
Related Issues (20)
- JSON: Cannot sub-query an array with only 1 element HOT 1
- -0.012345 in json returns a positive json_number HOT 3
- lexer_read gives wrong token data for '/' HOT 1
- Only one websocket frame is handled if multiple frames are received in single recv()
- Add license to mmx HOT 5
- sched.h name clash with system <sched.h>
- Typo in readme
- sdefl_compress reads past the bounds of the input array HOT 3
- sdefl not compatible with firefox built-in deflate method HOT 9
- Slow path detected when compressing a big file HOT 2
- deflate/inflate bug HOT 1
- Q: adding multiple jobs to scheduler
- License outdated in README HOT 1
- Assert triggers on deflate HOT 3
- `sdefl`: Possible corrupt DEFLATE stream generation under very specific circumstances HOT 7
- Integer overflow in sdefl_bound HOT 1
- Buffer overflow on input buffer in sdeflate HOT 1
- [sdefl] crash on `sdefl_compr()` after last update HOT 5
- Is it safe to call scheduler_add from a thread different then main
- json.h: json_obj_next() increments incorrectly if there is nesting
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lib.