cancel
Showing results for 
Search instead for 
Did you mean: 

Json Parsing issue in json generator

vaidyarm
Contributor

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…

4 REPLIES 4

viktor_n
Contributor II

Hi @vaidyarm,

You can do it with Apache Velocity.

[
  {
  #set( $a = "test json -->>" + $UserIds[0] + " test end ")
  "AccountId": "9999",
  "FeatureName": $a
  }
]

Output:
image

Regards,
Viktor

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"
  }
]

vaidyarm
Contributor

is $ sign cant be used in JSON generator?

Why you don’t just make this in Mapper?