Last Comment Bug 505211 - Add the JSON built-in object
: Add the JSON built-in object
Status: RESOLVED FIXED
:
Product: Rhino
Classification: Components
Component: Core (show other bugs)
: other
: All All
: -- enhancement (vote)
: ---
Assigned To: Norris Boyd
:
Mentors:
Depends on: 537483
Blocks: 489326
  Show dependency treegraph
 
Reported: 2009-07-20 05:43 PDT by rspeyer
Modified: 2010-01-01 18:28 PST (History)
1 user (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
initial implementation of JSON object (47.05 KB, patch)
2009-07-20 05:47 PDT, rspeyer
no flags Details | Diff | Splinter Review
updated JSON implementation (46.54 KB, patch)
2009-07-20 10:04 PDT, rspeyer
no flags Details | Diff | Splinter Review
simplified JsonLexer using regex'es (8.52 KB, patch)
2009-07-20 11:19 PDT, rspeyer
no flags Details | Diff | Splinter Review
added MPL to top of JsonLexer and JsonParser (4.70 KB, patch)
2009-07-21 09:03 PDT, rspeyer
no flags Details | Diff | Splinter Review

Description rspeyer 2009-07-20 05:43:03 PDT
User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-gb) AppleWebKit/530.18 (KHTML, like Gecko) Version/4.0.1 Safari/530.18
Build Identifier: Rhino 1.7 release 2 2009 03 22

As specified by 15.12 of the EcmaScript 5 spec.

http://wiki.ecmascript.org/doku.php?id=es3.1:es3.1_proposal_working_draft

Reproducible: Always
Comment 1 rspeyer 2009-07-20 05:47:46 PDT
Created attachment 389460 [details] [diff] [review]
initial implementation of JSON object

Assumes existence of of NativeArrayTest, which is added in attachment 386880 [details] [diff] [review] for bug 489329
Comment 2 rspeyer 2009-07-20 10:04:23 PDT
Created attachment 389501 [details] [diff] [review]
updated JSON implementation

Cleaned up the code a little and disallowed JSON numbers from starting with 0 unless their entire integral part is just '0'.
Comment 3 rspeyer 2009-07-20 11:19:24 PDT
Created attachment 389515 [details] [diff] [review]
simplified JsonLexer using regex'es
Comment 4 Norris Boyd 2009-07-20 18:15:29 PDT
Are JsonLexer and JsonParser from yajjl? If so, do you want to keep them under the original MIT license? If yes, I think we should have some indication of the license in the header of the file or in the directory. If you're willing to rerelease the source under the MPL (and others haven't contributed patches under that license), then can you add the MPL to the top of the file?
Comment 5 rspeyer 2009-07-21 09:03:37 PDT
Created attachment 389694 [details] [diff] [review]
added MPL to top of JsonLexer and JsonParser
Comment 6 Norris Boyd 2009-07-22 05:17:26 PDT
Looks great, thanks. I did tweak the formatting a bit and made some small changes to fix warnings I was seeing in Eclipse. I also added code to set the parent and proto of the wrapper object.

Checking in src/org/mozilla/javascript/NativeArray.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/NativeArray.java,v  <--  NativeArray.java
new revision: 1.103; previous revision: 1.102
done
RCS file: /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/NativeJSON.java,v
done
Checking in src/org/mozilla/javascript/NativeJSON.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/NativeJSON.java,v  <--  NativeJSON.java
initial revision: 1.1
done
Checking in src/org/mozilla/javascript/ScriptRuntime.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java,v  <--  ScriptRuntime.java
new revision: 1.314; previous revision: 1.313
done
RCS file: /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/json/JsonLexer.java,v
done
Checking in src/org/mozilla/javascript/json/JsonLexer.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/json/JsonLexer.java,v  <--  JsonLexer.java
initial revision: 1.1
done
RCS file: /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/json/JsonParser.java,v
done
Checking in src/org/mozilla/javascript/json/JsonParser.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/json/JsonParser.java,v  <--  JsonParser.java
initial revision: 1.1
done
Checking in testsrc/org/mozilla/javascript/tests/NativeArrayTest.java;
/cvsroot/mozilla/js/rhino/testsrc/org/mozilla/javascript/tests/NativeArrayTest.java,v  <--  NativeArrayTest.java
new revision: 1.2; previous revision: 1.1
done
RCS file: /cvsroot/mozilla/js/rhino/testsrc/org/mozilla/javascript/tests/json/JsonLexerTest.java,v
done
Checking in testsrc/org/mozilla/javascript/tests/json/JsonLexerTest.java;
/cvsroot/mozilla/js/rhino/testsrc/org/mozilla/javascript/tests/json/JsonLexerTest.java,v  <--  JsonLexerTest.java
initial revision: 1.1
done
RCS file: /cvsroot/mozilla/js/rhino/testsrc/org/mozilla/javascript/tests/json/JsonParserTest.java,v
done
Checking in testsrc/org/mozilla/javascript/tests/json/JsonParserTest.java;
/cvsroot/mozilla/js/rhino/testsrc/org/mozilla/javascript/tests/json/JsonParserTest.java,v  <--  JsonParserTest.java
initial revision: 1.1
done

Note You need to log in before you can comment on or make changes to this bug.