Skip to content

Instantly share code, notes, and snippets.

@lmatteis
Created April 27, 2012 07:52
Show Gist options
  • Save lmatteis/2507155 to your computer and use it in GitHub Desktop.
Save lmatteis/2507155 to your computer and use it in GitHub Desktop.
JSON.parse() not working correctly in Rhino?

Here's the JSON I'm trying to parse:

{"Name of submitting scientist":" Eva Weltzien","Institution":"ICRISAT Bamako","Language of submission (only in ISO 2 letter codes)":{"english":"En","french":"Fr"},"Date of submission":"11\/23\/2011","Crop":"Sorghum","Name of Trait":{"english":"Grain covering","french":"Couverture du Grain"},"Abbreviated name ":{"english":"GRNCOV","french":"CvGr"},"Trait ID for modification, Blank for New":{"english":"CO_324:0000043","french":""},"Description of Trait":{"english":"Amount of grain covered by glumes","french":"Observation Visuelle du degr\u00e9 de couverture du grain par les glumes \u00e0 la maturit\u00e9"},"How is this trait routinely used?":{"english":"Nursery","french":"P\u00e9pini\u00e8re"},"Trait Class":"Morphological","Name of method":{"english":"Grain Covering","french":"Ouverture des glumes"},"Describe how measured (method)":{"english":"Visual observation of the recovery level of grain by the glumes at maturity to give a score","french":"Observation visuelle du niveau de recouvrement du grain par les glumes \u00e0 la maturit\u00e9 pour donner un score"},"Growth stages":{"english":"Maturity","french":"Maturit\u00e9"},"Bibliographic Reference":{"english":"House, L.R. 1987. Manual for the selection of sorghum. Second edition. Patancheru, AP 502 324, India: International Crops Research Institute for the Semi-Arid Tropics.","french":"House, L.R. 1987. Manuel pour la selection du Sorgho. Deuxi\u00e8me \u00e9dition. Patancheru, A.P. 502 324, Inde: International Crops Research Institute for the Semi-Arid Tropics."},"Type of Measure (Continuous, Discrete or Categorical)":"Categorical","For Categorical: Name of rating scale":"Score(1-5)","For Categorical: Class 1 - value = meaning":{"english":"1= Grain surface completely covered","french":"1=Grain nu"},"For Categorical: Class 2 - value = meaning ":{"english":"2=25% Grain Surface Covered","french":"2=25% du grain recouvert"},"For Categorical: Class 3 - value = meaning":{"english":"3=50% Grain Surface Covered","french":"3=50% du grain recouvert"},"For Categorical: Class 4 - value = meaning":{"english":"4=75% Grain Surface Covered","french":"4=75% du grain recouvert"},"For Categorical: Class 5 - value = meaning":{"english":"5=Grain Surface completely not Covered","french":"5=Grain complement nu"},"ibfieldbook":"default","id":"CO_324:0000044","name":{"english":"Grain covering","french":"Couverture du Grain"},"ontology_name":"Sorghum","ontology_id":"CO_324","parent":"CO_324:M"}

If I use my browser's (Chrome) JSON.parse() method, everything works fine. If I use Rhino's JSON.parse() method, I get: org.mozilla.javascript.EcmaError: SyntaxError: String contains control character

@colinrwso2
Copy link

I've noticed this same behavior also. Did you find a workaround or fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment