Bug 34887 - Add API to directly expose JSON parsing
Summary: Add API to directly expose JSON parsing
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Oliver Hunt
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-12 04:57 PST by Oliver Hunt
Modified: 2010-03-18 13:51 PDT (History)
2 users (show)

See Also:


Attachments
Patch (4.13 KB, patch)
2010-02-12 04:59 PST, Oliver Hunt
no flags Details | Formatted Diff | Diff
Patch (9.11 KB, patch)
2010-03-11 01:00 PST, Oliver Hunt
no flags Details | Formatted Diff | Diff
Patch (8.85 KB, patch)
2010-03-18 13:38 PDT, Oliver Hunt
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Hunt 2010-02-12 04:57:01 PST
Add API to directly expose JSON parsing
Comment 1 Oliver Hunt 2010-02-12 04:59:30 PST
Created attachment 48637 [details]
Patch
Comment 2 Maciej Stachowiak 2010-02-12 05:02:49 PST
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.
Comment 3 Geoffrey Garen 2010-02-12 13:09:02 PST
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?
Comment 4 Eric Seidel (no email) 2010-02-17 14:23:37 PST
Attachment 48637 [details] was posted by a committer and has review+, assigning to Oliver Hunt for commit.
Comment 5 Oliver Hunt 2010-02-17 14:24:37 PST
Comment on attachment 48637 [details]
Patch

Clearing review flag, have changed api slightly and have new patch
Comment 6 Oliver Hunt 2010-03-11 01:00:32 PST
Created attachment 50479 [details]
Patch
Comment 7 Mark Rowe (bdash) 2010-03-11 11:55:22 PST
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!
Comment 8 Oliver Hunt 2010-03-18 13:38:04 PDT
Created attachment 51085 [details]
Patch
Comment 9 Eric Seidel (no email) 2010-03-18 13:43:35 PDT
Attachment 51085 [details] did not build on mac:
Build output: http://webkit-commit-queue.appspot.com/results/1021021
Comment 10 Oliver Hunt 2010-03-18 13:51:31 PDT
Committed r56189: <http://trac.webkit.org/changeset/56189>