1. David Pylatuk
  2. PowerBuilder
  3. Friday, 1 December 2023 16:12 PM UTC

Hello all,

 

Can anyone point me in the right direction to easily convert a JSON String -> XML and XML->JSON in PB2022?

Thanks in advance.

 

David Pylatuk Accepted Answer Pending Moderation
  1. Friday, 1 December 2023 21:29 PM UTC
  2. PowerBuilder
  3. # 1

I think I was over complicating it, this helps. Thanks.

Comment
  1. Chris Pollach @Appeon
  2. Friday, 1 December 2023 21:43 PM UTC
You are most welcome David!
  1. Helpful
There are no comments made yet.
David Pylatuk Accepted Answer Pending Moderation
  1. Friday, 1 December 2023 21:02 PM UTC
  2. PowerBuilder
  3. # 2

Thanks Chris,

XML->JSON is fairly straightforward using this;

long ll_ret, ll_RowCount
string ls_DWJson

ll_ret = XMLParseFile("C:\DAVEPYLATUK\HTTP Client Test\simplexml.txt")

dw_1.Reset()
IF ll_ret = 0 THEN
dw_1.ImportFile("C:\DAVEPYLATUK\HTTP Client Test\simplexml.txt", XML!)
ELSE
MessageBox("Import XML", "Failed", Information!)
END IF

ls_DWJson = dw_1.ExportJson(true)

ll_RowCount = dw_2.ImportJson(ls_DWJson)

mle_1.Text = ls_DWJson

 

The path to convert JSON->XML is not so clear to me yet.

Comment
  1. Chris Pollach @Appeon
  2. Friday, 1 December 2023 21:20 PM UTC
Once you have the JSON datum in a DWO - then I would just use the SaveAs (XML!) command. HTH
  1. Helpful 1
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 1 December 2023 16:32 PM UTC
  2. PowerBuilder
  3. # 3

Hi David;

  If this is plain 2D (rows & columns) JSON then I would suggest using a DataWindow & the ImportFile (XML!) command followed by an ExportJSON() command.  HTH
Regards >>> Chris

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.