Comments (4)
Not to mention that "gibberish" is never an appropriate way to describe texts because they're in non-Latin script.
from demjson.
I think the sanity check would do the correct thing if it was only used in strict mode, however there is a good reason to remove it there too
Indeed, ECMA-404 (since the 1st edition) and RFC 8259 both allow any value to appear at the top level of a JSON document, not just Arrays and Objects as specified in RFC 4627. This makes "あ"
valid JSON text, yet it fails the sanity check.
from demjson.
That sanity check does indeed seem rather useless (any encoding errors will hopefully be caught at a later point anyways) and wrong in at least two ways: It appears to rely on the RFC's statement that "the first two characters of a JSON text will always be ASCII characters" but ignores that A) when the RFC refers to "JSON text", it means a JSON object or array, not a simple value like a string and B) non-strict mode allows arbitrary unicode in unquoted identifiers.
The point of that statement in the RFC is not to allow more-or-less meaningless sanity checks but to show a way to detect the encoding (UTF-8/16/32) based on only the first two characters, and only when the input is a JSON object or array.
I think the sanity check would do the correct thing if it was only used in strict mode, however there is a good reason to remove it there too: It completely fails its stated goal of "rais[ing] a suitably descriptive error rather than an obscure syntax error later on", since the error message indicates improper unicode encoding while the actual problem is just as likely to actually be a syntax error (e.g. trying to decode something like {あ:2}
in strict mode).
from demjson.
Oh yeah, you are right. It took me a bit to look up the spec and write that up, and by the time I wrote that last part I had already forgotten that the sanity check is also used on values like strings.
EDIT: Although, the check does allow anything if the first character is a quote I believe, so it should not fail. Might have misread that part of the code though.
from demjson.
Related Issues (20)
- trailing whitespace
- high cpu load
- enum encode error:
- python -m demjson
- jsonlint changes foat values HOT 8
- Version on CentOS EPEL is out of date and exits 0 on errors HOT 2
- --allow=non-bmp HOT 4
- Code bug? HOT 2
- Failed to import under Python 2.7.13
- Documentation page is not opening HOT 2
- deron.meranda.us is Down, Causing Pip Installs to Fail HOT 1
- Importing ABC directly from collections module was removed in Python 3.9
- demjson.JSONDecodeError: ('Bad number', '.')
- syntax error
- To support numpy?
- Setuptools 58.0.0 has removed support for 2to3 during builds, breaks demjson for Python 3.x HOT 8
- demjson pip install fails with python3.7 and 3.7 but not 3.6. HOT 1
- Object literal (dictionary) is not terminated
- error in demjson setup command: use_2to3 is invalid. HOT 2
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 demjson.