hi Alan,
On 11/30/2012 4:12 PM, Alan Campin wrote:
OK, but how do you parse the JSON? There are all kinds of choices for
parsing XML including built into the RPG language. Hard for me to believe
that XML has that much overhead.
Parsing (as well as transferring) XML definitely adds some overhead...
probably takes 4 times as long as straight parameter passing... but,
whether that overhead matters in the greater scheme of things really
depends on the application. In most cases, I'd say it doesn't.
I use JSON every day, and prefer it over XML. I use a JSON parser named
YAJL, which is open source and written in C. I ported it to IBM i, and
have written an RPG front-end for it. It's extremely fast. I evaluated
some of the other JSON parsers available for RPG before I did this, but
none of them performed well enough for me. YAJL was the fastest I could
find.
Some day, when I'm less burned out (sigh), I'll make my IBM i port of
YAJL available to the community, and write some articles about it.
Having said that, I'm not sure that JSON is the right option here. One
problem with JSON is that the {, }, [, and ] characters that are so
heavily used in JSON are "variant" characters in EBCDIC, so they can be
a real pain to work with in EBCDIC unless all of your data is always in
the same CCSID. In fact, a purist would say that JSON should _always_
be UTF-8.
Now, in a web application, that's generally a non-issue, since UTF-8 is
the standard encoding of the web world. But, in a stored procedure
call, you'll doubtless be using EBCDIC. I'd probably just go ahead and
use XML in that case.
Though, frankily, Alan your idea of passing XML to a stored procedure
sounds remarkably like you're reinventing the wheel... since that's
pretty much what web services do. However, using a database stored
procedure call as a transport is much more limiting (32k parameter
limit, threat of a security compromise is higher, static connection is
more susceptible to problems on imperfect network connections, etc.)
What is your objection to using web services?
As an Amazon Associate we earn from qualifying purchases.