Create Nested-JSON for by parsing the records from database

@doug.burden
As per your guidance I was able to create a proper structure of nested JSON.
Please check below screenshot. In first screenshot, i’m able to create deep nested JSON.


When i copy paste this created nested jSON directly to API conncetor , then API works fine.
But when i’m trying to do in editor , I’m getting the below error for same JSON.

BAD_REQUEST “Can not parse a JSON”
I didn’t understand why the same JSON is giving error.

probably a string somewhere going rogue. you can try the :format as JSON safe syntax on all strings. also, make sure strings are strings and numbers are numbers

1 Like

@doug.burden
Sorry but I did not understand. :format as JSON safe should be applied on each and every field within the JSON?

Hey @doug.burden

I have made changes to API call and right now I have split the nested structure into parts.
{
“eventName”: “”,
“eventDesc”: “”,
“subcatId”: ,
“recurringFrom”: “”,
“recurringUntil”: “”,
“isPublic”: ,
“isActive”: true,
“langCode”: “”,
“recurringCode”: “”,
“sessionStartTime”: “”,
“sessionEndTime”: “”,
“sessionWeekdays”: “”,
“sessions”: [],
“channels”: []
}


For API initialisation I have set the dummy data but the same issue i’m facing over here is when we call the API, in debug it is giving the same issue that “can not parse JSON-- BAD REQUEST”

Is it reading nested json as text? What exactly is causing this error?

on your lang code try formatting as JSON safe

@doug.burden
Tried this for langcode but this is how it is looking “langCode”: ““en””,
just adding double quotes to langcode.
but it is not solving the JSON issue.
Still getting Can not parse JSON error.

well there is something in there that’s throwing it off. it could be anywhere. somewhere the format is wrong.

It looks like the problem is with your sessionChannels

You’re also adding {} in your api connector which is wrong take out the {} in the api connector and that might work

@doug.burden


If you talking about this is i have done for first time initialisation for API. So I think it is not adding {} to what we are doing with format as text is not adding extra braces to the JSON.

Is that correct or may be i misunderstood your point?

You know what you’ve actually got it where you’re pressing enter creating a break instead of keeping it all on one line.

You’re doing

{
“something”: “another something”,
“somethingElse”: “bananas”
}

It should be

{“something”: “another something”, “somethingElse”: “bananas”}

Write it like it’s 1 long sentence in the format as text

@doug.burden
Okay doug let me try this as well. I just hope it will resolve my problem.