Nathan,
because JSON is Javascript Object Notation, it is quite simple to use tools,
I use notepad++ and has JSON files marked as .js - then notepad++ will
tell you where the opposit af any bracket are.
In RPGLE I use my own nodeSupport that covers JSON, XML, HTML
tree/hierachical structures and makes
1. Encoding according to the format
2. tabulation and new lines insertion (unless you turn it off)
RPGLE Coding is very simple:
jsonNode('*array');
for i = 1 to 3;
__jsonNode('*object');
____jsonNode('*number':'messagenumber':%char(i));
____jsonNode('*string':'message':'Hello world, '
_____+'this is a very long message with special json char " in it');
____jsonNode('*string':'date':%char(%date(timeStamp)));
____jsonNode('*string':'time':%char(%time(timeStamp)));
__jsonEndNode();
endfor;
jsonEndNode();
Here are the very readable result with the treestructure to the left and
the json data
to the right:
http://85.24.84.163:1510/pextcgiCOR/testjson.pgm
Debug is also simple, I can just drop the generated code in a debug file
echoToStmf('/myJsonDebug.js':1208);
And it is all CGIDEV2 - with a little twist ;-) but it can be used in any
program because
what the above code does is just putting the generated JSON object in a
memory store
that can be retreived by its %addr and %size and then moved/added to any
other output
buffer.
And there are other free alternatives (I think Aaron uses this) with another
syntax and
approach:
http://www.rpgnextgen.com/
So there is a lot of help on the iSeries in the area of generating JSON from
RPGLE
and frankly I don't se any kind of performance problems, here is a smaller
message
and a typical responcetime I see on power6 machines with table lookup
http://85.24.84.163:1510/pextcgiCOR/testjson2.pgm
On Fri, Oct 15, 2010 at 1:14 AM, Nathan Andelin <nandelin@xxxxxxxxx> wrote:
Henrik,
I get your point about putting comma, open brace, & close brace delimiters
on
new lines. That makes JSON more readable. The indents don't appear in the
Web400 list, but I can see how that would help readability too.
-Nathan
As an Amazon Associate we earn from qualifying purchases.