Issue to Parse the Json output (Error: u,Detail: Unexpected token: u)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2023 06:49 AM
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2023 07:07 AM
Your error is not in the code that you have provided. There is no "u" token in this JSON or JavaScript.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2023 08:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2023 11:33 AM
Try without JSON.parse() if still not working use decode()
var parser = new global.JSON()
var parsedData = parser.decode(inputs.lis)