Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Native JSON.parse()?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Robert Ginda  
View profile  
 More options Apr 28 2010, 7:17 pm
From: Robert Ginda <rgi...@chromium.org>
Date: Wed, 28 Apr 2010 16:17:46 -0700
Local: Wed, Apr 28 2010 7:17 pm
Subject: [v8-users] Native JSON.parse()?
I'm working on a v8 embedding that needs to take a JSON file as a
command line argument.  I'd prefer not to Script::Run() it directly,
for the usual reason folks don't want to eval() json.  Is there a
native API for JSON.parse()?

Rob.

--
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephan Beal  
View profile   Translate to Translated (View Original)
 More options Apr 28 2010, 7:21 pm
From: Stephan Beal <sgb...@googlemail.com>
Date: Thu, 29 Apr 2010 01:21:30 +0200
Local: Wed, Apr 28 2010 7:21 pm
Subject: Re: [v8-users] Native JSON.parse()?

On Thu, Apr 29, 2010 at 1:17 AM, Robert Ginda <rgi...@chromium.org> wrote:
> I'm working on a v8 embedding that needs to take a JSON file as a
> command line argument.  I'd prefer not to Script::Run() it directly,
> for the usual reason folks don't want to eval() json.  Is there a
> native API for JSON.parse()?

You may want to check out the list of implementations near the bottom of the
page at:

http://json.org/

the only one of those i've used is jsoncpp, which is really simple to use
but also has a few incompatibilities with JS/JSON which might annoy or
hinder certain users (e.g. properties are stored in lexical sort order,
instead of their insertion order, and the default value for a JS var is null
instead of undefined (a value the framework doesn't account for at all)).

--
----- stephan beal
http://wanderinghorse.net/home/stephan/

--
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Ginda  
View profile  
 More options Apr 28 2010, 7:30 pm
From: Robert Ginda <rgi...@chromium.org>
Date: Wed, 28 Apr 2010 16:30:21 -0700
Local: Wed, Apr 28 2010 7:30 pm
Subject: Re: [v8-users] Native JSON.parse()?
Thanks for the quick reply, but I was hoping to use v8's native parser.

I imagine worst-case I can get a reference to the context's JSON.parse
function and Function::Call() it, which I'd prefer over adding another
dependency.

Rob.

--
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephan Beal  
View profile  
 More options Apr 28 2010, 7:46 pm
From: Stephan Beal <sgb...@googlemail.com>
Date: Thu, 29 Apr 2010 01:46:29 +0200
Local: Wed, Apr 28 2010 7:46 pm
Subject: Re: [v8-users] Native JSON.parse()?

On Thu, Apr 29, 2010 at 1:30 AM, Robert Ginda <rgi...@chromium.org> wrote:
> Thanks for the quick reply, but I was hoping to use v8's native parser.

> I imagine worst-case I can get a reference to the context's JSON.parse
> function and Function::Call() it, which I'd prefer over adding another
> dependency.

The v8 impl appears to be in parser.cc, as part of the Parser class. It's
not in the public API, so if you wanted to use it you'd have to declare the
internal types in your code (or import the v8-private headers) and then pray
that future changes to v8 do not invalidate the hackery.

On second thought - the internals you'd need from parser.cc are not declared
in parser.h, and appear to be private to that file... so good luck!

--
----- stephan beal
http://wanderinghorse.net/home/stephan/

--
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ryan Dahl  
View profile  
 More options Apr 28 2010, 9:02 pm
From: Ryan Dahl <coldredle...@gmail.com>
Date: Wed, 28 Apr 2010 18:02:30 -0700
Local: Wed, Apr 28 2010 9:02 pm
Subject: Re: [v8-users] Native JSON.parse()?

On Wed, Apr 28, 2010 at 4:17 PM, Robert Ginda <rgi...@chromium.org> wrote:
> I'm working on a v8 embedding that needs to take a JSON file as a
> command line argument.  I'd prefer not to Script::Run() it directly,
> for the usual reason folks don't want to eval() json.  Is there a
> native API for JSON.parse()?

Just assign it to some value:

  V8::Initialize();
  HandleScope handle_scope;
  Persistent<Context> context = Context::New();
  Context::Scope context_scope(context);
  context->Global()->Set(String::New("s"), String::New(argv[1]));
  Local<Script> script =
Script::Compile(String::new("JSON.parse(s);"),
String::New("parse.js"));
  Local<Value> result = script->Run();

--
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »