cancel
Showing results for 
Search instead for 
Did you mean: 

Need to change JSON response

swatifunde
Contributor

Hello Community,

I want to 9know how can I get below JSON response

{
“pvProjectID”: “2427827wj”,
“p6ActivityList”: [
{
“pvPprojectID”: “smhcvxsn,x”,
“pvActivityId”: “mxcxzvcb”,
“imo_Vorgangskategorie”: null,
“okz_Komponentenstruktur”: “01”,
“imo_Prozessnummer_Code”: “.Jnxbz1”,
“imo_ZugNummer”: “0m,xzn7”,
“imo_WagenNummer”: “Z”,
“activityName”: “xzb IT”,
“plannedFinishDate”: “2029-02-14T17:00:00.000”,
“blProjectFinish”: “2029-02-14T17:00:00.000”
},
{
“pvActivityId”: “FmzbxzcD”,
“imo_Vorgangskategorie”: null,
“okz_Komponentenstruktur”: “xzbvbzx1”,
“imo_Prozessnummer_Code”: “bxz0”,
“imo_ZugNummer”: “0z7”,
“imo_WagenNummer”: “Z”,
“activityName”: “cxcxzx g”,
“plannedFinishDate”: “2029-03-08T17:00:00.000”,
“blProjectFinish”: “2029-03-08T17:00:00.000”
}
],
“errorText”: “string”
}

Right now I managed to get response in below format
image

Can some one help me here

1 ACCEPTED SOLUTION

Apologies, the datatype is local datetime. That’s why.

I believe .toString() will do the job

View solution in original post

41 REPLIES 41

koryknick
Employee
Employee

@swatifunde - Thanks for following up. Take a look at this updated pipeline.
Community 13477 - Restructure JSON_2022_09_30.slp (11.6 KB)

The main logic to this is the Group By Fields snap that combines the data into a single array around your project id. The first Mapper snap moves the project id out of the $group_by element into the root where you want it. Then the second Mapper snap uses the new $p6ActivityList array as the root where we want make changes and we simply remove the project id from each level. If this syntax seems odd, review the documentation on the Mapper snap, particularly around the Pass Through option.
image

Great, its working as expected. Just small query , is it possible to remove first square bracket from final output?
image

koryknick
Employee
Employee

The surrounding square brackets represent the multiple documents in the data stream - in this case it is only one document but the data stream will always be an array. What is your target? Depending on your endpoint, this is usually correct - since it will output each document per each element of that surrounding array.

Hey @swatifunde,

I presume you exposing this as an api?
If that’s the case, than switch from document to binary output. Map
$ as $content, 200 as $status "application/json" as $['content-type'].

Hope this helps

yes, I am exposing this as an api. but I don’t understand solution here.
If I use Document to binary snap then how can I map this values.