05-25-2022 06:00 AM
I am trying to parse the below JSON in the JSON generator snap but getting the error.
Error: Expecting array for JSON-Path array index, found: Map
Payload :
[
{
“AccountId”: “9999”,
“FeatureName”: "test json -->>"$[0].UserIds[0]" test end "
}
]
It’s simple but still not getting through…
05-25-2022 06:18 AM
Hi @vaidyarm,
You can do it with Apache Velocity.
[
{
#set( $a = "test json -->>" + $UserIds[0] + " test end ")
"AccountId": "9999",
"FeatureName": $a
}
]
Output:
Regards,
Viktor
05-25-2022 06:31 AM
Hey @viktor_n ,
Actually, the problem is that “$[0].UserIds[0]” is not the value that I am trying to get from the pipeline, but it’s the text itself that is supposed to have $ signed value in it.
(its the Mysql query which allows querying JSON data by SQL itself)
https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html
Text i want to parse : select testfield->>‘$[0].exploreUserIds[0]’ as testfield from sampletable
Json through which i am trying to parse :
[
{
"AccountId": "9999",
"FeatureName": "select somefield->>'$[0].UserIds[0]' as testfield from sampletable"
}
]
05-26-2022 12:49 AM
is $ sign cant be used in JSON generator?
05-26-2022 02:41 AM
Why you don’t just make this in Mapper?