1. jay rajan
  2. PowerBuilder
  3. Wednesday, 10 June 2020 14:28 PM UTC

can anyone please help me....

I have  two datawindow..

dw_1 => one rows

 id = 1 , name =  a

 

dw_2 => two rows

id = , name = a,serial_no = 001,   address1= abc

id = , name = a,serial_no = 002,   address1= xyz

 

i want to create in following format

{

"id":"1",

"name":""a,

"details":[

                {

                      "id":"1","name":""a,"serial_no":"001", "addrees":"abc"

                 }

                {

                      "id":"1","name":""a,"serial_no":"002", "addrees":"xyz"

                 }

             ]

}

 

Yiannis Papadomichelakis Accepted Answer Pending Moderation
  1. Thursday, 11 June 2020 12:28 PM UTC
  2. PowerBuilder
  3. # 1

If you dont want to use a ready-made solution, you are doomed to create it by yourself!

 

All I can think of is to use JSONPackage. Export your first datawindow, load it on a JSONPackage variable, export the second datawindow and then use the SetValue(‘details’, jExp2) to complete the JSON. 

The obvious problem here is that datawindow export is creating a JSON array, not a json object, which means your export may look like this: [{"id":"1","name":""a}]

Since JSONPackage can not handle arrays (as far as I know), you have to remove the [] characters using string manipulation.

If you do that, then I see no problem creating the JSON string you described..

 

Comment
  1. jay rajan
  2. Thursday, 11 June 2020 14:21 PM UTC
I have already done this . this is not useful for me because i need to be modify the value after taking the one by one value from dw and before the createing json string so exportjson is not useful for me because it create directly so I can't apply moddification on values.

  1. Helpful
  1. jay rajan
  2. Thursday, 11 June 2020 14:24 PM UTC
I think i am very near to my solution.I will share you after comparing all posible solutions.. i will share with you....

Thanks you so much for your quick reply and support. thank you
  1. Helpful
There are no comments made yet.
Yiannis Papadomichelakis Accepted Answer Pending Moderation
  1. Thursday, 11 June 2020 09:29 AM UTC
  2. PowerBuilder
  3. # 2

This is very - very easy, if you use the json solution, created by Georg Brodbeck.

https://community.appeon.com/index.php/articles-blogs/tips-tricks-techniques-articles/17-powerbuilder/261-enhanced-json

 

If you ever used PBDOM for XML, you will feel very comfortable with this. In fact, it's more powerful than PBDOM. I used it a lot lately and I think it's very easy to accomplish what you want, using this simple library.

There is documentation and examples on GitHub. If you have questions about specific things, feel free to ask.

ah... and thank Georg for sharing his work with us!!!

 

Comment
  1. jay rajan
  2. Thursday, 11 June 2020 12:07 PM UTC
not preferring this bcaz its external ang going to fail for some datatype...........can you please ant other solution
  1. Helpful
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 10 June 2020 15:44 PM UTC
  2. PowerBuilder
  3. # 3

Why not use ExportJson and ExportRowAsJson functions?

Comment
  1. jay rajan
  2. Thursday, 11 June 2020 06:22 AM UTC
it is best for when we want indivisual jsom but in my case i want to combeine two dw json like header detail.

i want json in followng format.



"id":"1",



"name":""a,



"details":[



{



"id":"1","name":""a,"serial_no":"001", "addrees":"abc"



}



{



"id":"1","name":""a,"serial_no":"002", "addrees":"xyz"



}



]



}
  1. Helpful
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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.