#5725 closed defect (fixed)
Parsing bad JSON text should throw an error
Reported by: | kriszyp | Owned by: | Adam Peller |
---|---|---|---|
Priority: | high | Milestone: | 1.1 |
Component: | General | Version: | 1.0 |
Keywords: | json | Cc: | alex |
Blocked By: | Blocking: |
Description
When Dojo.fromJson is called with an invalid Json string, it returns the provided string when it should fail (throw an exception). It is irrational to return a wrong result rather than failing.
Attachments (2)
Change History (9)
Changed 14 years ago by
comment:1 Changed 14 years ago by
Cc: | alex added |
---|
we agree. technically, this would violate compatibility, but it's the right thing to do. thoughts?
comment:2 Changed 14 years ago by
Sounds reasonable. I plan to post a patch to support complex queries in ItemFile?Store. It uses a string argument to "query", which works fine...except when dojo parses markup, it (I assume it is the parser) assumes the value of "query=" should be a json object and at some point dojo.fromJson is called. It now just prints a syntax error to console. Making the above change prior to finding where and possibly correcting the markup parsing will break the complex query patch. Guidance?
comment:3 Changed 14 years ago by
You could change ItemFileReadStore? to make query a string parameter, and then in the constructor manually convert it to a JS object. Take the parser out of the equation. For programmatic creation, still allow query to be specified as a string or an object and then in the constructor do { if ( typeof this.query == "String" )
comment:4 Changed 14 years ago by
comment:5 Changed 14 years ago by
Owner: | changed from anonymous to Adam Peller |
---|
comment:7 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
patched json.js