On Mon, 17 Jun 2019, Allin Cottrell wrote:
On Sat, 15 Jun 2019, Artur Tarassow wrote:
> Dear all,
>
> I hope you had a successful gretl conference in Naples!
>
> I am currently working with json files again. Using latest git version of
> gretl on Ubuntu linux (even though the behavior also occurs for older
> versions), I've found that some of the json-elements grabbed are not of the
> expected datatype. See the the following example and the file attached:
>
>
> <hansl>
> string PATH2JSON = "/home/at/tmp/" # set your path
> string jsonfile = sprintf("%s/ex_json_num_vector.json", PATH2JSON)
> string jread = readfile("@jsonfile")
> bundle B = jsongetb(jread)
> b = B.JSON
>
> # Evaluate type of elements
> #-----------------------------------------------------
> # Item Expected Is
> # v1 string null
> # v2 string array string array
> # v3 scalar scalar
> # v4 matrix string array
>
> loop i=1..nelem(b) -q
> string str = "v$i"
> eval b["@str"]
> eval typestr(typeof(b["@str"]))
> print ""
> endloop
> </hansl>
>
> Is there a rational reason for this behavior?
Not really. It seems that typeof() is not reaching inside bundles to
find the type of their contents. That should be made to happen.
Ah, that comment was not quite right: the failure of typeof() to reach
inside bundles (and arrays) was specific to the case of string
objects. That's now fixed in git; snapshots will follow.
Allin