|
On Mar 19, 2018, at 2:46 PM, Mark Murphy <jmarkmurphy@xxxxxxxxx> wrote:
I don't know about that. XML-INTO handles missing or extra elements, and
name spaces with options and prefixes. DATA/XML-FROM could work similarly.
For example:
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 numeric
elements with a value of 0 could result in a missing element. Or an option
could control that. A count field with a prefix option could be used to
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 few
ways to create valid JSON as opposed to XML. JSON has no name-space to deal
with, and no schemas either. There is no need to differentiate between
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 is
a collection of values. A string is surrounded by double quotes, a number
isn't. An object is surrounded by curly braces, and a list is surrounded by
square brackets. That is the whole spec.
On Mon, Mar 19, 2018 at 3:15 PM, Jon Paris <jon.paris@xxxxxxxxxxxxxx> wrote:
Easier said than done Mark.--
COBOL has an XML generation capability built in - but most of the time you
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 even
worse as the rules are not as strict as for XML and people do really
strange things.
Jon Paris
www.partner400.com
www.SystemiDeveloper.com
On Mar 19, 2018, at 9:22 AM, Mark Murphy <jmarkmurphy@xxxxxxxxx> wrote:wrote:
Great, now all we need to complete that picture is a DATA-FROM (and maybe
even an XML-FROM) to make it simple to produce JSON or whatever data
interchange format from a data structure.
On Fri, Mar 16, 2018 at 4:55 PM, Barbara Morris <bmorris@xxxxxxxxxx>
such
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 language,
haveas JSON. The big difference between DATA-INTO and XML-INTO is that you
mailing list--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) (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
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
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
link: http://amzn.to/2dEadiD
Help support midrange.com by shopping at amazon.com with our affiliate
--
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
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.