Note: There are a few cases of duplicates in user autocompletion which are being worked on.

Implement JS_ParseJSON, JS_ParseJSONWithReviver

RESOLVED FIXED in mozilla5



JavaScript Engine
6 years ago
6 years ago


(Reporter: Waldo, Assigned: Waldo)




Firefox Tracking Flags

(Not tracked)


(Whiteboard: fixed-in-tracemonkey)


(1 attachment, 1 obsolete attachment)

Created attachment 520727 [details] [diff] [review]
Patch, also add some simple-ish JSAPI tests for them

Almost all callers of JS_BeginJSONParse/JS_ConsumeJSONText/JS_EndJSONParse would really rather have an API where they can just provide source characters and get back the object you get by parsing it.  We should give them such an API, rather than requiring a tedious three-step.  And since so far no one uses the reviver functionality, we should add a separate API to use it: keep the most common API simple, and leave the less-common case under its own separate heading.

There's more refactoring to come in this area, and eventually these method implementations won't just directly implement the begin-consume-finish idiom.  But it seems best to separate out that cleanup from the initial additions: more patches, but smaller and simpler patches.
Attachment #520727 - Flags: review?(brendan)
Created attachment 520738 [details] [diff] [review]
Fix thinko
Attachment #520727 - Attachment is obsolete: true
Attachment #520727 - Flags: review?(brendan)
Attachment #520738 - Flags: review?(brendan)
Comment on attachment 520738 [details] [diff] [review]
Fix thinko

This is one I will duck due to Servo ramping up. Trying Luke.

Attachment #520738 - Flags: review?(brendan) → review?(luke)

Comment 3

6 years ago
Comment on attachment 520738 [details] [diff] [review]
Fix thinko

Nice observation.

>+extern JS_FRIEND_API(JSBool)
>+ParseJSONWithReviver(JSContext *cx, const jschar *chars, uint32 length, const Value &filter,
>+                    Value *vp, DecodingMode decodingMode = STRICT);


Also, we have this new jsfriendapi.h... should we use it as such (in support of the eventual goal of not having code outside js/src #include into js/src)?
Attachment #520738 - Flags: review?(luke) → review+

There's entanglement of the friend API with enums defined in json.h, and it looked messy disentangling things, and we really really really don't want to encourage use of this anyway, and the APIs here are changing anyway to make the JSON parsing work easier, so I didn't make that change.
This landed in TM and later got merged to m-c:
Last Resolved: 6 years ago
Resolution: --- → FIXED
Whiteboard: fixed-in-tracemonkey
Target Milestone: --- → mozilla5 (which also documents the *WithReviver special-case)
Keywords: dev-doc-complete
You need to log in before you can comment on or make changes to this bug.