|
Mark
just to clarify - JSON is a text notation of a javascript object - so like
at javascript object
it may start with either an object "{" litteral or an array "[" litteral so
this is perfectly valid
JSON:
[ { "propertyA" : "abc", "propertyB" : "def" }, { "propertyA" : "ghi",
"propertyB" : "jkl" } ]
another thing is that JSON is not easy unless your program language and
thereby your
editor (like VSCODE) supports the format - if you just use notepad you end
up in a
comma hell.
The easiest way to create JSON are actually in javascript where you do no
create a
string you add to but creates an object that you are able to manipulate as
you like e.g.
you can create the whole body first and then at sections (e.g. rows) as you
go an when
finished create the string in one instruction (JSON.stringify())
For other languages (including RPG) there is YAJL that simulates the
Javascript Object
in some extent.
In regards to creating XML, Jon Paris wrote a section in the Modernization
Manual
describing severel methods and plugins to do the job (amoung those my own)
so it
is just a matter of doing like anybody alese - look in the Open Source
community where
you often find a solution that even includes procedures for sending or
saving your generated
documents and also does the rigtht encoding of special characters.
Or last but not at least, go for SQL that for some seems to be the problem
for all lacking
wishes in RPG.
On Mon, Mar 19, 2018 at 8:46 PM, Mark Murphy <jmarkmurphy@xxxxxxxxx>
wrote:
I don't know about that. XML-INTO handles missing or extra elements, andsimilarly.
name spaces with options and prefixes. DATA/XML-FROM could work
For example:numeric
Options could define an attributePrefix=atr_ then
dcl-ds accounts;
dcl-ds account dim(99);
Id char(6);
name char(30);
end-ds;
end-ds;
Should result in:
<accounts>
<account>
<id>xxxxxx</id>
<name>name stuff</name>
</accoun>
<account>
<id>yyyyyy</id>
<name>name stuff</name>
</accoun>
....
</accounts>
and
dcl-ds accounts;
dcl-ds account dim(99);
atr_Id char(6);
name char(30);
end-ds;
end-ds;
Should result in:
<accounts>
<account "id=xxxxxx">
<name>name stuff</name>
</accoun>
<account "id=yyyyyy">
<name>name stuff</name>
</accoun>
....
</accounts>
Blank character fields could result in a missing element. Likewise
elements with a value of 0 could result in a missing element. Or anoption
could control that. A count field with a prefix option could be used tofew
specify the number of elements to produce for multiple elements.
I would expect generation of JSON to be even easier as there are only a
ways to create valid JSON as opposed to XML. JSON has no name-space todeal
with, and no schemas either. There is no need to differentiate betweenis
attributes and values, JSON has only values. JSON always starts with an
object which is a collection of name:value pairs. A name is always a
string. A value can be a string, a number, a list, or an object. A list
a collection of values. A string is surrounded by double quotes, a numberby
isn't. An object is surrounded by curly braces, and a list is surrounded
square brackets. That is the whole spec.even
On Mon, Mar 19, 2018 at 3:15 PM, Jon Paris <jon.paris@xxxxxxxxxxxxxx>
wrote:
Easier said than done Mark.you
COBOL has an XML generation capability built in - but most of the time
still need to transform it before it can be used.
For example - given a DS like this:
dcl-ds accounts;
dcl-ds account dim(99);
Id char(6);
name char(30);
end-ds;
end-ds;
Should that result in:
<accounts>
<account>
<id>xxxxxx</id>
<name>name stuff</name>
</accoun>
<account>
<id>yyyyyy</id>
<name>name stuff</name>
</accoun>
....
</accounts>
Or
<accounts>
<account "id=xxxxxx">
<name>name stuff</name>
</accoun>
<account "id=yyyyyy">
<name>name stuff</name>
</accoun>
....
</accounts>
And that is just a trivial example. I suspect for JSON it would be
affiliateworse as the rules are not as strict as for XML and people do reallywrote:
strange things.
Jon Paris
www.partner400.com
www.SystemiDeveloper.com
On Mar 19, 2018, at 9:22 AM, Mark Murphy <jmarkmurphy@xxxxxxxxx>
maybe
Great, now all we need to complete that picture is a DATA-FROM (and
language,even an XML-FROM) to make it simple to produce JSON or whatever datawrote:
interchange format from a data structure.
On Fri, Mar 16, 2018 at 4:55 PM, Barbara Morris <bmorris@xxxxxxxxxx>
On 2018-03-16 11:35 AM, Barbara Morris wrote:
The latest enhancement for RPG is available for 7.2 and 7.3: The
DATA-INTO opcode. It's like XML-INTO, but for any structured
suchyou
as JSON. The big difference between DATA-INTO and XML-INTO is that
have(RPG400-L)
to supply the parser for the structured language.
Here's a article by Jon Paris about DATA-INTO:
http://ibmsystemsmag.com/ibmi/developer/rpg/rpg-data-into/
--
Barbara
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
affiliatemailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our
(RPG400-L)link: http://amzn.to/2dEadiD--
This is the RPG programming on the IBM i (AS/400 and iSeries)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxquestions.
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
Help support midrange.com by shopping at amazon.com with our
(RPG400-L)link: http://amzn.to/2dEadiD
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
mailing list--
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
--
Regards,
Henrik Rützou
http://powerEXT.org <http://powerext.org/>
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.