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
13866 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
0
TJ
A Score Level 2
over 8 years ago
Alternatively, could you state the reason for which you need dictionary type. Lets try to reverse engineer your problem statement.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 8 years ago
Looking at the values there, is the input string something like "[id:,category:Cat 1,desc:tickets,code:12348,amount:123.43]"...? If that's the case, there's no easy way of casting that to a dictionary - you'll have to figure out a way of parsing that string into individual fields using functions like split().
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Rama Thummala
Certified Lead Developer
over 8 years ago
AFAIK, we don't have direct function to do so. Need to write expression rules to extract data from text, and form data for dictionary.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 8 years ago
Maybe this helps:
forum.appian.com/.../Text_Functions.html
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
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
+1
mikej117
over 8 years ago
Thanks for all the useful replies. I think that we will probably change the format of the Text string so it contains JSON formatted data, which will make it easy to convert, whilst not affecting the data type.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Reject Answer
Cancel
0
aloks0189
Certified Lead Developer
over 8 years ago
@mikej117 that's Correct, here 'local!jsonData' is of type Text and contains JSON Form of Data which again gets converted back to List of Dictionary Format using fromJson().
Happy to help
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel