Add API to directly expose JSON parsing
Created attachment 48637 [details] Patch
Comment on attachment 48637 [details] Patch r=me but please put the declaration in a private header until this can go through Mac OS X API review.
I think "JSValueMakeFromJSONString" would be a better name than "JSValueMakeValueFromJSONString". All other functions like this are JSValueMake* rather than JSValueMakeValue*. Did you decide to leave out JSValueCreateJSONString, or is that coming in another patch?
Attachment 48637 [details] was posted by a committer and has review+, assigning to Oliver Hunt for commit.
Comment on attachment 48637 [details] Patch Clearing review flag, have changed api slightly and have new patch
Created attachment 50479 [details] Patch
Comment on attachment 50479 [details] Patch > +/* Converting to and from JSON formatted strings */ > + > +/*! > + @function > + @abstract Creates a JavaScript value from a JSON formatted string. > + @param ctx The execution context to use. > + @param string The JSString containing the JSON string to be parsed. > + @result A JSValue containing the parsed value, or NULL if the input is invalid. > + */ > +JS_EXPORT JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef string); > + > +/*! > + @function > + @abstract Creates a JavaScript string containing the JSON serialized representation of a JS value. > + @param ctx The execution context to use. > + @param value The value to serialize. > + @param indent The number of spaces to indent when nesting. If 0, the resulting JSON will not contains newlines. The size of the indent is clamped to 10 spaces. > + @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. > + @result A JSString with the result of serialization, or NULL if an exception is thrown. > + */ > +JS_EXPORT JSStringRef JSValueCreateJSONString(JSContextRef ctx, JSValueRef value, unsigned indent, JSValueRef* exception); These two functions need to be tagged in the header with availability macros indicating which version of JavaScriptCore they were introduced with. > + Please don’t add trailing white space. > /*! > @@ -248,7 +270,7 @@ JS_EXPORT JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JS > @result The JSObject result of conversion, or NULL if an exception is thrown. > */ > JS_EXPORT JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception); > - > + Same here!
Created attachment 51085 [details] Patch
Attachment 51085 [details] did not build on mac: Build output: http://webkit-commit-queue.appspot.com/results/1021021
Committed r56189: <http://trac.webkit.org/changeset/56189>