1. Ragy Ibrahim
  2. PowerBuilder
  3. Monday, 19 September 2022 14:27 PM UTC

Hello every body can any one help parsing this json

[
{
"hashed_id": "had1568",
"retailer_number": "01062165935",
"order_details.*": [
{
"Item": "167",
"quantity": 10,
"price": 50,
"tax": 0
},
{
"Item": "100",
"quantity": 10,
"price": 50,
"tax": 0
}
]
},
{
"hashed_id": "157565iu",
"retailer_number": "01062165935",
"order_details.*": [
{
"Item": "167",
"quantity": 10,
"price": 50,
"tax": 0
},
{
"Item": "100",
"quantity": 10,
"price": 50,
"tax": 0
}
]
}
]

Accepted Answer
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Wednesday, 21 September 2022 05:43 AM UTC
  2. PowerBuilder
  3. # Permalink

Hello,

Here is the project, attached as a zip file, to parse the JSON mentioned above.   Developed using PB 2019 R3 2703.   

HTH

Happiness Always
BKR Sivaprakash

 

Attachments (1)
Comment
  1. Ragy Ibrahim
  2. Wednesday, 21 September 2022 09:25 AM UTC
thanks @Sivaprakash BKR I sincerely appreciate your help with the project , its really great effort and i appreciate it and it is really helpful..✿
  1. Helpful
  1. Sivaprakash BKR
  2. Wednesday, 21 September 2022 10:55 AM UTC
Welcome Ragy. I gained a lot from this community and trying to help others.

  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 19 September 2022 14:54 PM UTC
  2. PowerBuilder
  3. # 1

Hi Ragy;

  You would use the built-in PB JSONParser object class. It has methods for processing both Parent & Child branches and their various property values.

  FWIW: I use my Firefox web browser to view the JSON I'm coding for. It displays the JSON in its proper TreeView breakdown.

HTH

Regards ... Chris 

Comment
  1. Ragy Ibrahim
  2. Monday, 19 September 2022 21:34 PM UTC
thank you for commenting but iam new with json parsing and i couldn't find any easy way to parse this json and import to datawindow
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Monday, 19 September 2022 22:00 PM UTC
  2. PowerBuilder
  3. # 2

If you are wanting to import the data in the JSON string into a DataWindow, look in PB Help at the "ImportJson method (DataWindows)" help topic.

Personally, I think you'll learn much more by figuring out how to accomplish this on your own.

I had to learn how to parse a JSON string recently as I had never done so before, and it isn't difficult. The Help topics for each of the various JSON-related objects and methods nearly always contain code snippets/examples. Working through the steps by myself helped me become more comfortable with the process, so I encourage you to try.

Best regards, John

Comment
  1. Ragy Ibrahim
  2. Tuesday, 20 September 2022 12:02 PM UTC
i tried and i can parse one parent and multi child my issue is multi parent and multi child i couldn't find a way to parse it

[

{

"hashed_id": "had1568",

"retailer_number": "01062165935",

"order_details": [

{

"Item": "110",

"quantity": 12.00,

"price": 55.5,

"tax": 0.00

},

{

"Item": "120",

"quantity": 17.00,

"price": 55.5,

"tax": 0.00

},

{

"Item": "130",

"quantity": 13.5,

"price": 50.0,

"tax": 0.00

}

]

},

{

"hashed_id": "1536AQ",

"retailer_number": "01016696690",

"order_details": [

{

"Item": "140",

"quantity": 12.00,

"price": 55.5,

"tax": 0.00

},

{

"Item": "150",

"quantity": 17.00,

"price": 55.5,

"tax": 0.00

},

{

"Item": "160",

"quantity": 13.5,

"price": 50.0,

"tax": 0.00

}

]

}

]
  1. Helpful
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Tuesday, 20 September 2022 06:02 AM UTC
  2. PowerBuilder
  3. # 3

Hello,

My suggestion would be to look into this utility

https://community.appeon.com/index.php/codeexchange/powerbuilder/250-u-json-object-oriented-json-in-pb#266

And example how to parse and add is given here [ This matches your requirement ]

https://github.com/informaticon/inc.win.base.pb-json/wiki/Examples

HTH

Happiness Always
BKR Sivaprakash

 

Comment
  1. Ragy Ibrahim
  2. Tuesday, 20 September 2022 12:00 PM UTC
it worked with me only when i have one parent and multi child but when i tried multi parent and multi child doesn't work

[

{

"hashed_id": "had1568",

"retailer_number": "01062165935",

"order_details": [

{

"Item": "110",

"quantity": 12.00,

"price": 55.5,

"tax": 0.00

},

{

"Item": "120",

"quantity": 17.00,

"price": 55.5,

"tax": 0.00

},

{

"Item": "130",

"quantity": 13.5,

"price": 50.0,

"tax": 0.00

}

]

},

{

"hashed_id": "1536AQ",

"retailer_number": "01016696690",

"order_details": [

{

"Item": "140",

"quantity": 12.00,

"price": 55.5,

"tax": 0.00

},

{

"Item": "150",

"quantity": 17.00,

"price": 55.5,

"tax": 0.00

},

{

"Item": "160",

"quantity": 13.5,

"price": 50.0,

"tax": 0.00

}

]

}

]
  1. Helpful
There are no comments made yet.
Ragy Ibrahim Accepted Answer Pending Moderation
  1. Wednesday, 21 September 2022 09:28 AM UTC
  2. PowerBuilder
  3. # 4

Hello,

Here is the project, attached as a zip file, to parse the JSON mentioned above.   Developed using PB 2019 R3 2703.   

HTH

Happiness Always
BKR Sivaprakash

thanks @Sivaprakash BKR I sincerely appreciate your help with the project , its really great effort and i appreciate it and it is really helpful..✿

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.