pretty format json in progress 4gl

Posted by ankitshukla on 15-Jan-2015 09:50

Hi all,

How to make my json file as pretty format? I am having json file which is have everything in single line. I want it to be formatted manner.

Any help will be highly appreciable.

Thanks,

All Replies

Posted by Peter Judge on 15-Jan-2015 10:02

How are you creating it? And what version of OE?
 
The WRITE-JSON() function has an option to write the out formatted JSON .
If you're on 11.0+, take a look at the JsonObject/JsonArray; they both have a WriteFile() method which takes an argument for formatting.
 
If you have a file you got from somewhere else, and you're using PDSOE/OE Architect, take a look at the JSON Tools plugin (https://marketplace.eclipse.org/content/json-tools) which can do pretty formatting.
 
Hth,
-- peter
 
[collapse]
From: ankitshukla [mailto:bounce-ankitshukla@community.progress.com]
Sent: Thursday, 15 January, 2015 10:51
To: TU.OE.General@community.progress.com
Subject: [Technical Users - OE General] pretty format json in progress 4gl
 
Thread created by ankitshukla

Hi all,

How to make my json file as pretty format? I am having json file which is have everything in single line. I want it to be formatted manner.

Any help will be highly appreciable.

Thanks,

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by ankitshukla on 15-Jan-2015 10:17

I am having progress version 10.2b. And the file I am getting from somewhere else and i just want to make this file pretty formatted by using any progress function or method before reading....I am not going to use the write-json() method.

Posted by Peter Judge on 15-Jan-2015 10:28

There's no built-in JSON handling in 10.2B, in ABL anyway. You could (depending on your service pack and platform) look into using the .NET bridge together with the System.Json classes.
 
If you're not on Windows, then you will need to either write your own parser, or find a 3rd-party library (I know some exists, but can't remember their names at the moment).
 
hth,
-- peter
 
[collapse]
From: ankitshukla [mailto:bounce-ankitshukla@community.progress.com]
Sent: Thursday, 15 January, 2015 11:18
To: TU.OE.General@community.progress.com
Subject: RE: [Technical Users - OE General] pretty format json in progress 4gl
 
Reply by ankitshukla

I am having progress version 10.2b. And the file I am getting from somewhere else and i just want to make this file pretty formatted by using any progress function or method before reading....I am not going to use the write-json() method.

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by egarcia on 15-Jan-2015 10:39

Hello,

Just a quick suggestion.

If you need to do this process programmatically, you could probably use Node.js and use the JSON object.

The JSON.stringify() has a parameter to format the JSON output.

If you do not need to do it programmatically, could use http://jsonlint.com/

Are you using a custom parser? Why do you need to format the JSON before reading?

I hope this helps.

Posted by ankitshukla on 16-Jan-2015 06:58

I need some code written in progress 4gl (open edge 10.2b) not in jquery or javascript.

This thread is closed