Json formatting issue

spandana3
Tera Contributor

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 

 

var tt = {};
tt.a = "test";
tt.b = "check";

var pp = JSON.parse(tt);
gs.print(pp.a);
6 REPLIES 6

Robbie
Kilo Patron
Kilo Patron

Hi @spandana3,

 

There are a few things to understand here, so I've used your code and variables with comments to help explain.

See below:

 

 

//Here you're creating an object named 'tt'
var tt = {};
tt.a = "test";
tt.b = "check";

//JSON.parse converts text into a JavaScript object, however, tt is already an object, so you don't need this line. I have commented it out
//var pp = JSON.parse(tt);

//Simply print out using your object 'tt' and the attribute 'a' as below
gs.print(tt.a);

 

 

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie

 

 

 

Pankaj Jadhav
Tera Contributor

I'm getting the same error while creating attachments on the target instance using the Import set API.
json body
{"records":[{"u_file_name":"RE_ Critical INC4202597 Server is down .msg","u_table_name":"incident","u_content_type":"application/octet-stream","u_number":"INC6530122","u_size_bytes":"1154048","u_compressed":"true","u_hash":"","u_base64_data":"fdgshdkkdf=-="},{"u_file_name":"RE_ Critical INC4202597 - server is down .msg","u_table_name":"incident","u_content_type":"application/octet-stream","u_number":"INC6530122","u_size_bytes":"1154048","u_compressed":"true","u_hash":"","u_base64_data":"fdgshdkkdf=-="}]}

 

Response:

No associated crypto module sys_id found in the DB for the module key: 229af203db130110cd149c26f49619df
No associated crypto module sys_id found in the DB for the ephemeral key: 229af203db130110cd149c26f49619df
Found keyId : c04fcfcfdbdf015069189c26f49619bd in store : com.glide.kmf.KMFDBModuleKeyStore@1fce841
Found wrapped key in repo. Attempting to unwrap.
Successfully unwrapped key
AMU52: {"import_set_id":"1b27d79b1bfbca581d5d744c8b4bcbf2","multi_import_set_id":"1b27d79b1bfbca581d5d744c8b4bcbf3"}
Evaluator: com.glide.script.RhinoEcmaError: Unexpected token: o script : Line(155) column(0)