Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Issue to Parse the Json output (Error: u,Detail: Unexpected token: u)

Vamshi_ch123
Tera Contributor

Hi,

Hi I have content as below and i tried to parse the output with the script step in the flow actions but I was getting below error how to fix this issue

[{
"account_status" : "EXPIRED & LOCKED",
"all_shard" : "NO",
"authentication_type" : "PASSWORD",
"common" : "YES",
"created" : "Thu Jan 26 14:24:27 UTC 2017",
"default_collation" : "COMP",
"default_tablespace" : "USERS",

}, {
"account_status" : "OPEN",
"all_shard" : "NO",
"authentication_type" : "PASSWORD",
"common" : "NO",
"created" : "Fri Aug 21 09:04:58 UTC 2020",
"default_collation" : "USING_NLS_COMP",
"default_tablespace" : "IMP_TBS",

}]

                               to 

account_status : EXPIRED & LOCKED
all_shard : NO
authentication_type : PASSWORD
common" : "YES",
created : Thu Jan 26 14:24:27 UTC 2017
default_collation : COMP
default_tablespace : USERS


account_status : OPEN
all_shard : NO
authentication_type : PASSWORD
common : NO
created : Fri Aug 21 09:04:58 UTC 2020
default_collation : USING_NLS_COMP
default_tablespace" : IMP_TBS

 

Script:

var list = JSON.parse(inputs.lis);
//alert("before "+list.length);
//alert("After "+list.length);
for (var i = 0; i < list.length; i++) {
str += '' +
'account_status : ' + list[i]['account_status'] + '\n' +
'all_shard : ' + list[i]['all_shard'] + '\n' +
'authentication_type : ' + list[i]['authentication_type'] + '\n' +
'common : ' + list[i]['common'] + '\n ' +
'created : ' + list[i]['created'] + '\n' +
'default_collation : ' + list[i]['default_collation'] + '\n' +
'default_tablespace : ' + list[i]['default_tablespace'] + '\n' +

str += '\n\n\n\n';
}
str += '';

outputs.output = str;

Vamshi_ch123_0-1679838572145.png

 

3 REPLIES 3

GLewis5
Tera Guru

Your error is not in the code that you have provided. There is no "u" token in this JSON or JavaScript.

hi @GLewis5 

thanks for the reply. can you please suggest how to fix this?

 

thanks

@Vamshi_ch123 ,

 

Try without JSON.parse() if still not working use decode()

 

var parser = new global.JSON()
var parsedData = parser.decode(inputs.lis)