- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2019 06:00 AM
Hello,
Does anybody know how to get the length of a JSON Array in CCX Scripting?
I have the following JSON:
{
"value": [
{
"item1": 1,
"item2": 2
},
{
"item1": 3,
"item2": 4
},
]
}
So, this is an array of 2 items.
I tried to use the step Get JSON Document Data, using values such as "$.value[length]". This filter works in http://jsonpath.com/, but CCX does not recognize it.
Is there an easy way to get this information? Maybe with a Java step (preferably not importing any Class to CCX).
Thank you,
Bruno
Solved! Go to Solution.
- Labels:
-
UCCX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2019 10:37 AM
https://github.com/json-path/JsonPath
And therefore, you're testing should be done in a jayway compliant tester:
https://jsonpath.herokuapp.com/
You'll notice that in jayway you would use the following syntax to obtain the length of an array:
"$.value.length()"
And you'll need to assign it to an int type variable. See if that gets you where you want to be.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2019 10:37 AM
https://github.com/json-path/JsonPath
And therefore, you're testing should be done in a jayway compliant tester:
https://jsonpath.herokuapp.com/
You'll notice that in jayway you would use the following syntax to obtain the length of an array:
"$.value.length()"
And you'll need to assign it to an int type variable. See if that gets you where you want to be.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2019 11:24 AM
That's it, mate! :)
Thank you so much!!!
Bruno
