Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Verified Answer
+1
person also asked this
people also asked this
Replies
3 replies
Subscribers
7 subscribers
Views
4845 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Expected Behavior for a!fromJson()
seanw583
over 7 years ago
Hi,
We're using JSON strings to populate different SAIL components. Part of our use case involves fetching the length of an array that is stored within the JSON string. Using length() doesn't work in this case, it always returns 1. I've attached an example code snippet demonstrating this. Is this the expected behavior? If so, is there an alternative to length() that will get the correct array length?
I'm attaching screenshots of sample code showing this behavior. The first sample shows an array of length 3, when cast to and back from JSON will return length() = 1. The second sample shows that indexing the same array works as expected, and the final sample is the only workaround I could come up with. I was hoping there would be a cleaner solution than using apply over a casting function.
OriginalPostID-255970
JSON Array Behavior.docx
Discussion posts and replies are publicly visible
Parents
+1
monikar
over 7 years ago
Below code works the same way as the workaround from your attachment without using apply
length(tointeger({a!fromJson(
a!toJson(
{
jsonArray: {3,4,5,6}
}
)
).jsonArray}))
Cancel
Vote Up
0
Vote Down
Sign in to reply
Reject Answer
Cancel
Reply
+1
monikar
over 7 years ago
Below code works the same way as the workaround from your attachment without using apply
length(tointeger({a!fromJson(
a!toJson(
{
jsonArray: {3,4,5,6}
}
)
).jsonArray}))
Cancel
Vote Up
0
Vote Down
Sign in to reply
Reject Answer
Cancel
Children
No Data