|
View previous topic :: View next topic
|
| Author |
Message |
divated
New User
Joined: 30 Sep 2016 Posts: 5 Location: south africa
|
|
|
|
Hello,
I am getting below JSON DFHRESPONSE in my CICS webservice call.
| Code: |
{
"prov_name": "GAUTENG ",
"city_name": [
"JNB1 ",
"JNB2 "
],
"suburb_name": [
"SUBURB1 ",
"SUBURB2 "
],
"message_status": 0,
"response_message": "successful "
} |
but i am expecting the below response.
| Code: |
{
[
{
"province_name": "GAUTENG ",
"region_name": "PRETORIA ",
"suburb_name": "SAULSVILLE "
},
{
"province_name": "GAUTENG ",
"region_name": "PRETORIA ",
"suburb_name": "SAULSVILLE UIT 4 "
}
],
"message_status": 0,
"response_message": "successful "
}
|
this is how i have defined by array.
| Code: |
01 WS-ARRAY-FIELDS.
05 WS-POST-RECORDS OCCURS 1 TO 500 TIMES
DEPENDING ON W01-TOTAL-CNT.
10 LB-PROVINCE-N PIC X(13) VALUE '"prov_name":"'.
10 WS-PROVINCE-NAME PIC X(100).
10 FILLER PIC X(02) VALUE '",'.
10 LB-REGION-N PIC X(13) VALUE '"city_name":"'.
10 WS-REGION-NAME PIC X(100).
10 FILLER PIC X(02) VALUE '",'.
10 LB-SUBURB-N PIC X(15) VALUE '"suburb_name":"'.
10 WS-SUBURB-NAME PIC X(100).
10 FILLER PIC X(02) VALUE '",'. |
|
|
| Back to top |
|
 |
Robert Sample
Global Moderator

Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
First, your expected results do not match your defined array -- the variable LB-REGION-N is defined as "city_name" and hence will NEVER be "region_name" as you expect.
Second, there is pretty much no JSON expertise on this forum so you're probably not going to get many (if any) answers here. Your best bet is to do LOTS of debugging -- displaying the ENTIRE value you get back, then figuring out how your program is parsing it out into variables. Or you could convince your management to hire a consultant to help you figure out your issues. |
|
| Back to top |
|
 |
divated
New User
Joined: 30 Sep 2016 Posts: 5 Location: south africa
|
|
|
|
Sorry for confusing with the different field labels.
But my question is related to grouping.
My table has values
province city suburb
abc jnb sub1
abc jnb sub2
All i want in my result is grouping ( province, city and suburb) as groups
but my current results are giving me all separate group for province, and separate for city and separate for suburb.
The grouping is shown by [ ], which is not generated correctly. |
|
| Back to top |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
Your logic to create/build the response is Not right. So, the code where you are doing the grouping doesn't seem to be correct.
Moreover, If you have a field with X(100) then you'll get:
| Code: |
| "prov_name": "GAUTENG ", |
i.e. spaces after value and don't expect the value to be like below, unless you modify it:
| Code: |
| "province_name": "GAUTENG ", |
. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|