On Wed, Apr 28, 2010 at 4:17 PM, Robert Ginda <[email protected]> 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
[email protected]
http://groups.google.com/group/v8-users

Reply via email to