[ardoJSON] Path returned multiple tokens

[ardoJSON] Path returned multiple tokens

  
Forge Component
(22)
Published on 5 Sep by Ricardo Silva
22 votes
Published on 5 Sep by Ricardo Silva

Hi,

I'm using Plataform Version 9.0, Java Stack and ardoJSON Version 1.9.

When i use "JSONSelect" method to return more than one result, the extension gives me this error:

"Path returned multiple tokens."

Is there a workaround to resolve this problem?


Below a simple example of what i'm doing:

Method: JSONSelect

Input Parameters:

JSON:

{
   "LstListagem":[
      {
         "Number":"2342314000106"
      },
      {
         "Number":"123456"
      },
      {
         "Number":"321654"
      },
      {
         "Number":"2342314000106"
      }
   ]
}

Path:

LstListagem..[?(@.Number=='2342314000106')]


Should Return:

[
   {
      "Number":"2342314000106"
   },
   {
      "Number":"2342314000106"
   }
]


It gives me this error: 

Path returned multiple tokens.


Thanks.

Hello,

Sorry for the extremely late reply, but I don't remember implementing this kind of select syntax on ardoJSON.

Maybe you have replaced the implementation with one of your own which properly supports that syntax?

Could you provide us with your current implementation so I can compare the implementations?

Best regards,

Ricardo Silva

Solution

Hi Ricardo,


I tried another approach to my case and everything worked smoothly.

I used Goessner jSON Path (http://goessner.net/articles/JsonPath/) and using RunJavascript action, the case that i opened the topic has been resolved.


Here is an example of what i did to resolve my case:


SyntaxEditor Code Snippet

 var parsedJson = jQuery.parseJSON('"+OutSystems2JSON.JSON+"');
    var result = JSONPath({json: parsedJson, path: '$LstListagem..[?(@.Number=='2342314000106')]'});


OutSystems2JSON.JSON -> An example RecordList parsed to JSON

var parsedJson -> Receives the json string that needs to be parsed 

var result -> will receive the json that contains only the "Number" attribute '2342314000106'

Solution