09-23-2022 07:57 AM
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
Can some one help me here
Solved! Go to Solution.
10-06-2022 06:42 AM
Apologies, the datatype is local datetime. That’s why.
I believe .toString()
will do the job
09-30-2022 05:44 AM
@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.
10-03-2022 02:12 AM
Great, its working as expected. Just small query , is it possible to remove first square bracket from final output?
10-03-2022 05:19 AM
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.
10-03-2022 07:48 AM
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
10-04-2022 12:14 AM
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.