BTW, that's because "{" will be read as a JavaScript statement grouping:

 {
   var x = 3;
   ...
 }

By putting "0," before that, you guarantee that it is read as an object.

You can also use

y = javascript('JSON.parse(\"'+x+'"\")')

where x is JSON encoded. I could imagine that would be a bit faster,
because it is using a more restricted vocabulary.



On Mon, Dec 21, 2015 at 7:11 PM, Robert Hanson <hans...@stolaf.edu> wrote:

> Javascript cannot eval("{test:'here'}")
>
> add "0," before that.
>
>
>
> On Mon, Dec 21, 2015 at 10:24 AM, Rolf Huehne <rhue...@leibniz-fli.de>
> wrote:
>
>> On 12/18/2015 06:41 PM, Robert Hanson wrote:
>> > x = null
>> > y = null
>> > t = now();
>> > x = load("tt.json")
>> > print "ms to read " + x.length + " bytes: " + now(t)
>> > t = now()
>> > y = javascript(x)
>> > print "ms to translate JSON to Jmol variables: " + now(t)
>> >
>> > ms to read 58696197 bytes: 12313
>> > ms to translate JSON to Jmol variables: 25286
>> >
>> Bob, is this already available in Jmol 14.4.1_2015_12_20?
>>
>> I tried the example above with the large JSON example and got the
>> following error message in Firefox 42.0 on Linux with JSmol/HTML5:
>>
>> ---- Error message --------------------------------
>> SyntaxError: missing ; before statement try/catch path:
>> 0 function (b,d)
>>   args[0]=SyntaxError: missing ; before statement
>>   args[1]=function (){a.instantialize(this,arguments)}
>> 1 J.appletjs.Jmol.doEval(a)
>>   args[0]={ "edgeKeysUsed": { "species||Neurospora crassa%%ageingFacto...
>> 2 JU.GenericApplet.eval(a)
>>   args[0]={ "edgeKeysUsed": { "species||Neurospora crassa%%ageingFacto...
>> 3 JV.StatusManager.jsEval(a)
>>   args[0]={ "edgeKeysUsed": { "species||Neurospora crassa%%ageingFacto...
>> 4 JV.Viewer.jsEvalSV(a)
>>   args[0]={ "edgeKeysUsed": { "species||Neurospora crassa%%ageingFacto...
>> 5 JS.MathExt.evaluateScript(d,a,b)
>>   args[0]=[JS.ScriptMathProcessor object]
>>   args[1]=Token[string(4/0x4) value="{ "edgeKeysUsed": { "species||Neu...
>>   args[2]=134238732
>> 6 JS.MathExt.evaluate(d,a,b,c)
>>   args[0]=[JS.ScriptMathProcessor object]
>>   args[1]=Token[keyword(12/0x800520c) value="javascript"]
>>   args[2]=Token[string(4/0x4) value="{ "edgeKeysUsed": { "species||Neu...
>>   args[3]=134238732
>> 7 JS.ScriptMathProcessor.evaluateFunction(a)
>>   args[0]=134238732
>> 8 JS.ScriptMathProcessor.addOpAllowMath(a,b,c)
>>   args[0]=Token[keyword(17/0x10000011) value=")"]
>>   args[1]=true
>>   args[2]=0
>> 9 JS.ScriptMathProcessor.addOp(a)
>>   args[0]=Token[keyword(17/0x10000011) value=")"]
>> ---------------------------------------------------
>>
>> I also tried JSmol/Java. The first time the java plugin crashed. The
>> second time is running since more than an hour now. Although the java
>> process doesn't uses any CPU time. So I am not sure if there is still
>> happening something.
>>
>> Regards,
>> Rolf
>>
>> --
>>
>> Rolf Huehne
>> Postdoc
>>
>> Leibniz Institute on Aging - Fritz Lipmann Institute (FLI)
>> Beutenbergstrasse 11
>> 07745 Jena, Germany
>>
>> Phone:   +49 3641 65 6205
>> Fax:     +49 3641 65 6210
>> E-Mail:  rhue...@leibniz-fli.de
>> Website: http://www.leibniz-fli.de
>>
>>            Scientific Director: Prof. Dr. K. Lenhard Rudolph
>>         Head of Administration: Dr. Daniele Barthel
>> Chairman of Board of Trustees: Burkhard Zinner
>>
>> VAT No: DE 153 925 464
>> Register of Associations: No. 230296, Amtsgericht Jena
>> Tax Number: 162/141/08228
>>
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Jmol-users mailing list
>> Jmol-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>>
>
>
>
> --
> Robert M. Hanson
> Larson-Anderson Professor of Chemistry
> Chair, Department of Chemistry
> St. Olaf College
> Northfield, MN
> http://www.stolaf.edu/people/hansonr
>
>
> If nature does not answer first what we want,
> it is better to take what answer we get.
>
> -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
>
>


-- 
Robert M. Hanson
Larson-Anderson Professor of Chemistry
Chair, Department of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr


If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
------------------------------------------------------------------------------
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to