Json formatting issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 09:24 AM
I am trying to below script in background script , but receiving an error as
Evaluator: com.glide.script.RhinoEcmaError: Unexpected token: o script : Line(155) column(0)
Can any one suggest what went wrong in the below script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 09:48 AM
"tt" is not a valid JSON string. So you cannot use the parse function. Here is an example using JSON parse:
var str = '{"name":"George","lastname":"Washington"}';
var obj = JSON.parse(str);
gs.info('The first name is ' + obj.name);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 09:54 AM
Either that or you want to do JSON.stringify instead of JSON.parse.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 10:00 AM
Hi @spandana3 ,
The error "Evaluator: com.glide.script.RhinoEcmaError: Unexpected token: o script : Line(155) column(0)" indicates that the script is trying to parse an invalid JSON format. In your case, the issue is that you're attempting to parse a JavaScript object (tt) as JSON using JSON.parse().
Here's a breakdown of the problem and how to fix it:
tt is an Object, Not JSON: The variable tt is a simple JavaScript object with properties a and b. JSON is a data format used to transmit data between systems, and it has a specific structure.
No Need to Parse Objects: Since tt is already a JavaScript object, you don't need to parse it with JSON.parse(). This function is meant for converting valid JSON strings into JavaScript objects.
Here's the corrected script:
var tt = {};
tt.a = "test";
tt.b = "check";
// No need to parse tt as it's already an object
gs.print(tt.a); // This will print "test"
This version directly accesses the property a of the tt object using dot notation.
If you intend to convert the object tt into a JSON string, you can use JSON.stringify():
var tt = {};
tt.a = "test";
tt.b = "check";
varjsonString = JSON.stringify(tt);
gs.print(jsonString); // This will print a JSON string representing the
I hope this explanation helps!
Please let me know if this helps! You can mark this answer as "Correct" if it resolves your issue, and "Helpful" if you find it valuable.
Thanks,
Astik Thombare

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 10:01 AM
@spandana3 JSON.parse method is used to create an object from a JSON formatted string.
Here is an example.
var str = '{"name":"George","lastname":"Washington"}';
var obj = JSON.parse(str);
gs.info('The first name is ' + obj.name);
Since you already created an object in javascript, you do not have to use parse method on tt object.
You can simply use the following code to print the value of a property in tt object.
var tt = {};
tt.a = "test";
tt.b = "check";
gs.print(tt.a);
gs.print(tt.b);
Hope this helps.