Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get rhino to convert json #135

Closed
steowens opened this issue Apr 25, 2014 · 3 comments
Closed

Unable to get rhino to convert json #135

steowens opened this issue Apr 25, 2014 · 3 comments

Comments

@steowens
Copy link

The following unit test fails due to the fact that Rhino 1.7r4 does not initialize the global scope with JSON:

@Test
public void findOutTypeReturnedFromRhino() throws JsonProcessingException{
    String jsScript = "function f(){ return JSON.stringify({property1:\"hello\", array1:[{subobject:1}]}); } f();";
    Context jsContext = Context.enter();
    Scriptable jsScope= jsContext.initStandardObjects();
    Object result = jsContext.evaluateString(jsScope, jsScript, "myscript.js", 1, null);
    System.out.println(result.getClass().getName());    
}

The exception returned is:
org.mozilla.javascript.EcmaError: ReferenceError: "JSON" is not defined. (myscript.js#1)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557)
... more ...

@gbrail
Copy link
Collaborator

gbrail commented Jan 30, 2015

This seems to be working OK in 1.7R5. Can you re-test?

@steowens
Copy link
Author

Will do

gbrail pushed a commit that referenced this issue May 13, 2019
@tonygermano
Copy link
Contributor

@gbrail I think this can be closed. A test case was added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants