#1 2014-07-04 09:57:18

chula
Member
Registered: 2014-06-18
Posts: 19

How to reference a JSON value when the key name is numeric?

say v := _JSON('{result:{data:{"1000":"D1", "1001":"D2",..........


v.result and v.result.data return properly.

v.result.data.Exists('1000') returned True. Of course there is no  v.result.data.1000 syntax.

How to get the value of key '1000'?

Thanks!

Offline

#2 2014-07-04 10:31:20

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,603
Website

Re: How to reference a JSON value when the key name is numeric?

You can use DocVariantData(v.result.data).Value['1000'].

I just added the aDocVariant.Value(aName) and aDocVariant._(aName) pseudo methods, which can be used with late-binding.
So that now you can write also: v.result.data.Value('1000') since v.result.data.1000 won't compile.
See http://synopse.info/fossil/info/47805bc15e118

Offline

#3 2014-07-04 10:35:28

chula
Member
Registered: 2014-06-18
Posts: 19

Re: How to reference a JSON value when the key name is numeric?

ab wrote:

You can use DocVariantData(v.result.data).Value['1000'].

I just added the aDocVariant.Value(aName) and aDocVariant._(aName) pseudo methods, which can be used with late-binding.
So that now you can write also: v.result.data.Value('1000') since v.result.data.1000 won't compile.
See http://synopse.info/fossil/info/47805bc15e118


Really cool, thanks very much!

Offline

Board footer

Powered by FluxBB