Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Suggested Answer
Replies
7 replies
Answers
1 answer
Subscribers
8 subscribers
Views
13894 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Convert Text into Dictionary
mikej117
over 8 years ago
Hello data conversion experts!
I am trying to convert some data that is being stored as a Text data type into a List of Dictionary data type. I've tried a few different things, such as converting to and from JSON (this gives me a List of Text output), and also tried casting the value. No luck. Has anyone managed to do this in an Appian expression rule?
Here's my current rule that seems to always return an empty Dictionary (note that ri!value is a Text Array):
cast(
194, /* magic number for type: 'List of Dictionary' */
ri!value
)
OriginalPostID-244347
Discussion posts and replies are publicly visible
Parents
0
aloks0189
Certified Lead Developer
over 8 years ago
@mikej117 as per your requirement, the steps which you have mention for this solution is correct, there might be some small mistake. However for such requirement where i have a Text Data type which holds the JSON values, we can get that data back in List in Dictionary Format using a!fromJson() function, as i have tested it and working perfectly, below is the Code, please have a look on that which may help you to resolve your problem Statement
==================================================
load(
/*Storing Some Data Into local variable*/
local!data: a!queryEntity(
entity: cons!EmployeeDetailsConstant,
query: a!query(
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: 50
)
)
).data,
/*Converting the data into JSON Text and storing into a local variable*/
local!jsonData: a!toJson(local!data),
/*To get the Type of local!jsonData*/
/*typename(typeof(local!jsonData))*/
/*Fetching the data from JSON Text to List of Dictionary Format*/
a!fromJson(local!jsonData)
)
=========================================================
I Hope this will Help You
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
aloks0189
Certified Lead Developer
over 8 years ago
@mikej117 as per your requirement, the steps which you have mention for this solution is correct, there might be some small mistake. However for such requirement where i have a Text Data type which holds the JSON values, we can get that data back in List in Dictionary Format using a!fromJson() function, as i have tested it and working perfectly, below is the Code, please have a look on that which may help you to resolve your problem Statement
==================================================
load(
/*Storing Some Data Into local variable*/
local!data: a!queryEntity(
entity: cons!EmployeeDetailsConstant,
query: a!query(
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: 50
)
)
).data,
/*Converting the data into JSON Text and storing into a local variable*/
local!jsonData: a!toJson(local!data),
/*To get the Type of local!jsonData*/
/*typename(typeof(local!jsonData))*/
/*Fetching the data from JSON Text to List of Dictionary Format*/
a!fromJson(local!jsonData)
)
=========================================================
I Hope this will Help You
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data