Greetings,
Let me first thank you guys for all answers.
Brad's one worked well and sorted it out.
--
Cheers,
Nihat.
date: Sat, 3 Dec 2016 16:19:44 -0600
from: Bradley Stone <bvstone@xxxxxxxxx>
subject: Re: Parsing JSON array without a name
I believe this should be done like this:
D docNode s like(yajl_val)
D node s like(yajl_val)
D ids s like(yajl_val)
D arrayNode s like(yajl_val)
D id s 500a varying
D i s 10i 0
D errMsg s 500a varying inz('')
docNode = //Loading the JSON data;
// position node to "data"
node = YAJL_object_find(docNode : 'data');
//position ids to the array
ids = YAJL_object_find(node: 'generatedIds');
//parse the array
dow YAJL_ARRAY_LOOP(ids:i:arrayNode);
id = yajl_get_string(arrayNode);
//process each id value
enddo;
I have a whole bunch of other JSON building and parsing examples here:
http://fieldexit.com/forum/thread?groupid=Prog&forumid=POC
I did format the code in this to fixed width so I hope it comes through ok. Otherwise you should just be able to copy and paste it into your editor.
Brad
www.bvstools.com
On Sat, Dec 3, 2016 at 2:16 PM, Nihat Ezer <Nihat.Ezer@xxxxxxxxxxxxxx>
wrote:
Greetings,
The following is JSON data subject to my question:
{"data":{"generatedIds":["4Uz+N55BR2SMxKQWyHOTpA=="]},"
success":true,"error":null,"validations":null }
Using YAJL API by Scott Klement and struggling with parsing the JSON
data returned from a web service cal. I can successfully read the
values for the "data", "generatedIds" and the first and last element
of the array. Because the array element does not have a name, I cannot retrieve its value.
node = YAJL_object_find(docNode : 'data'); node =
YAJL_object_find(node:'generatedIds');
node = YAJL_ARRAY_ELEM(node:1);
node = YAJL_object_find(node: ___ );
genId = yajl_get_string(node);
Thanks,
Nihat.
[
https://www.avivasa.com.tr/i/Assets/images//otomatik-katilim-imza-1.jpg]<
https://www.avivasa.com.tr/bes-otomatik-katilim-nedir>
Bu e-postanin içerdigi bilgiler (ekleri dahil olmak üzere) gizlidir. Onayimiz olmaksizin üçüncü kisilere açiklanamaz. Bu mesajin gönderilmek istendigi kisi degilseniz, lütfen mesaji sisteminizden derhal siliniz. AvivaSA Emeklilik ve Hayat A.S. bu mesajin içerdigi bilgilerin dogrulugu veya eksiksiz oldugu konusunda bir garanti vermemektedir. Bu nedenle bilgilerin ne sekilde olursa olsun içeriginden, iletilmesinden, alinmasindan, saklanmasindan sorumlu degildir. Bu mesajin bilinen virüslere karsi kontrolleri AvivaSA Emeklilik ve Hayat A.S. tarafindan yapilmistir. Ancak internet iletisiminde güvenlik ve hatasiz gönderim garanti edilemeyeceginden, mesajin yerine ulasmamasi, geç ulasmasi, içeriginin bozulmasi ya da mesajin virüs tasimasi gibi problemler olusabilir. AvivaSA Emeklilik ve Hayat A.S. bu tip sorunlardan sorumlu tutulmaz. Bu mesajin içerigi yazarina ait olup AvivaSA Emeklilik ve Hayat A.S.'nin görüslerini içermeyebilir.
The information contained in this e-mail (including any attachments) is confidential. It must not be disclosed to any person without our authority. If you are not the intended recipient, please delete it from your system immediately. AvivaSA Emeklilik ve Hayat A.S. makes no warranty as to the accuracy or completeness of any information contained in this message and hereby excludes any liability of any kind for the information contained therein or for the information transmission, reception, storage or use of such in any way whatsoever. This message is scanned for known viruses by AvivaSA Emeklilik ve Hayat A.S. But Internet communications cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, arrive late or contain viruses. The AvivaSA Emeklilik ve Hayat A.S. therefore does not accept liability for any errors or omissions in the context of this message which arise as a result of Internet transmission. Any opinions expressed in this message are those of the author and may not necessarily reflect the opinions of AvivaSA Emeklilik ve Hayat A.S.
As an Amazon Associate we earn from qualifying purchases.