Sorry, for the late reply. I was away for a couple of days.
Am 28.02.19 um 23:14 schrieb Allin Cottrell:
On Thu, 28 Feb 2019, Sven Schreiber wrote:
> Am 28.02.2019 um 19:03 schrieb Allin Cottrell:
>> On Thu, 28 Feb 2019, Sven Schreiber wrote:
>
>>> I'm still talking about stuff I don't fully understand, but maybe we
>>> should have a hansl function that writes out the contents of a
>>> bundle (or let's say, a well-defined subset of possible contents) as
>>> a json string or file.
>>
>> bwrite() already serializes a bundle as XML. Is there a substantial
>> advantage in having a JSON serialization too? If so, is that best
>> done by writing a new serialization, or by transcoding the XML?
>> (Googling "convert XML to JSON" shows up tons of transcoding options.)
>
> Artur can perhaps give a better answer, but my impression with xml is
> that it is too generic. You can do a lot of stuff with it, but in the
> end that requires to have some clever xslt or similar thing which for
> me basically means the same amount of work as simply exporting it in
> the desired format in the first place.
>
> So what's the use of a gretl bundle written out in xml from, say,
> Python's point of view? Well, given the nice xml tools for Python I
> can imagine it's not too difficult to get a tailor-made solution to
> grab the matrices in there. So yes, maybe the json thing isn't needed.
Interesting ideas all round, but before pursuing them it would seem to
be worth figuring out: What are the actual targets? (That is, the other
software to which we'd like to be able to pass gretl bundles.) And what
can they (best) parse? Can they happily read JSON but not XML, or vice
versa?
As said here, my original post was just to show how to use a
JSON-configuration file which is readable by gretl and other software
packages such as Python, R and Julia. At work, JSON (as well as even
simple yaml-files) files are mainly used as configuration files having a
very simple structure as I have tried to show in my original post. Sven
then had the idea of using JSON as an exchange format.
I think Allin is right when asking for what purpose one wants to
implement these ideas. When working with the "foreign-block" interacting
and exchanging objects with other software packages, XML may be the
right format from gretl's perspective as gretl already has the bread()
and bwrite() functions for such purposes.
And as already mentioned here, there exist read/write XML packages for
all popular software packages such as R, Python and Julia (the packages
I would personally focus on). Also, transformation from XML to JSON and
vice versa can be become quite costly I guess -- if possible let's avoid
this.
Also, if I am not totally wrong, gretl's XML handling covers more data
types --- actually all which can be put into a gretl bundle --- compared
to what can be handled with jsonget(). The help file only lists the
handling of: double (floating-point), int (integer) and strings.
The relevant tools are readily available in the free software domain
(e.g. libxml2 and json-glib). But if target software S is "without such
tools" (i.e. doesn't link to such libraries and expose their
functionality natively, as with gretl's jsonget and xmlget) it would
probably be a rather massive job to implement them in S's language. IMO,
S would have to offer some very special value-added to make this
worthwhile.
I would say that if language S has not implemented such freely available
tools, it's not "our" task to write a library for S. In this case,
interaction is strictly limited to the exchange of simple ascii files.
Best,
Artur