When using a JSON Parser to parse the output from a Web Request, the following JSON is producing the error “Enter a valid JSON payload”. This happens when I try to click the “Generate Output” option.
When manually entering in JSON Path expression like “$.0].slot_id”, which should result in “1791”, the result is instead empty.
Page 1 / 1
Hello @jkampman
Hope you are well,
The Payload provided looks to be in a Array of Json, A Json object would be this alone:
{"slot_id":"1791","kiosk_id":"Denver","cabinet_id":"1"}. So if you’d like to get the data of the Slot_id under the array of Json, You could try something like $.0].0].slot_id and it should get you the data.
Hope this helps! Thanks!
Let me know incase of queries!
stike that reading the above, I’m an idiot.
Ammar, would this work for grabbing an email from the quoted array:
Also, where am I placing ‘$.$0]00].email’ in the web request, expression builder or in the JSON Parser somewhere?
@Ammar KB sorry forgot to tag you!
Hi @Brendan_08
No worries!
You’d be adding this in the JSON parser itself, Please find an example below:
This would be shown in “insert Placeholders” -->Parser fields:
Hope this helps!
@Ammar KB like this:
@Brendan_08 Yes, That’s right, But we would be breaking down Array-based elements, For instance if you consider my earlier picture of Json parser, I’m breaking an Array of Strings of conversations from a ticket and taking in the 1st conversation alone by adding d0] to the new element to get the first value:
Similarly what you have is an Array of Json objects and hence you’d have to make it 2-dimensional, where the first e0] would be the first array out of 2 arrays and 2nd a0] would be the first element of the first array.
Apologies for not elaborating this in earlier replies. Hope this helps! Feel free to reach out to us at support@freshservice.com too for more queries!
Yeah, I have a ticket open with support, but they said:
“Hi Brendan,
I think the product team needs to consider this use case and build this natively so that it takes an array into consideration and does not throw an error.
I will keep you posted with more updates on this. Thanks! “
So I’m not sure they will be much help.
Apologies, I missed out your earlier reply:
In this case, You need not have 0]]0].email, Since you’ve already generated the output for this whole Array, You can simply use insert Placeholders to print the value. That should work
If not I’ll see if anyone in the community can help me with this, I don’t think support will be much help. Also I guess I should learn about this stuff in general.