Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
4 replies
Subscribers
7 subscribers
Views
3422 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
handle list of multiple parameters in a!fromJSon
TJ
A Score Level 2
over 7 years ago
If I may continue the post:
forum.appian.com/.../e-197406
I stumbled upto the similar issue where I get list multiple parameters from restful web-service and I am not able to index the label value pair. Could you please help.
For eg:
{"Employee":[{"Name":"ABC","Address":[{"addr1":"address line 1","addr2":"address Line 2","city":"London","Country":"UK"},
{"addr1":"address line 1","addr2":"address Line 2","city":"Mexico City","Country":"Mexico"}]}]}
If i use a!fromJson and index the value, I am able to index Name but not Address. Address length appear to be 1 and i cant further index using addr1, or city, etc.
Please help!
OriginalPostID-241375
Discussion posts and replies are publicly visible
0
chetany
A Score Level 1
over 7 years ago
Is the rule input "value" of type text?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
chetany
A Score Level 1
over 7 years ago
Ok, I was able to parse it. Address length is indeed one. The expression editor will indicate that its a List of Variant. And indeed it contains only one element. I am able to extract the other attributes like City.
For city, I got London; Mexico City as output. For addr1 I got address line 1; address line 1 as output.
The expression I used is:
with(
local!a: a!fromJson(ri!value),
local!a.Employee.Address[1].city
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
venkateshs329
over 7 years ago
Hi ,
As of my knowledge,
I tried below code its working fine and it will gives output, but when i pass value as rule input(text) it give an Error.
load(
local!value:{"Employee":{{"Name":"ABC","Address":{{"addr1":"address line 1","addr2":"address1 Line 2","city":"London","Country":"UK"},
{"addr1":"address line 1","addr2":"address2 Line 2","city":"Mexico City","Country":"Mexico"}}}}},
local!a: a!toJson(local!value),
local!fromJson:a!fromJson(local!a),
local!fromJson.Employee.Address[1].addr2
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
TJ
A Score Level 2
over 7 years ago
Thanks Chetan. So the conclusion is to use index 1 for every list type parameter with a!fromJson() output. Though unexpected, its consistent behavior for dictionary type.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel