× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I agree it could be done with options etc. but they could never be as generic I suspect as those of XML-INTO. I was just trying to point out that it seem trivial until you realize that somebody else makes the rules and you re trying to generate something that matches. This is particularly true it seems to me with JSON where the rules are more liberal.

All I know is that COBOL has had the kind of facility that Barbara describes and it goes largely unused because it cannot readily produce the formats defined by web service providers etc. without pre-processing. If you get to define the format of the JSON and XML yourself it is a different story.


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

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:

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>
wrote:

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,
such
as JSON. The big difference between DATA-INTO and XML-INTO is that you
have
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)
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

--
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 thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.