[quickjs-devel] Re: How to iterate an object in c++ code?

  • From: Guido Grassel <guido.grassel@xxxxxxxxxx>
  • To: "quickjs-devel@xxxxxxxxxxxxx" <quickjs-devel@xxxxxxxxxxxxx>
  • Date: Fri, 3 Jan 2020 08:46:20 +0000

Hi!

If this is a string that is JSON encoded, you first need to decode the string 
to get JS objects (JSValue)  that you can then read / write from C.
Use JS_ParseJson(..)

If you already have JS objects, you need to check their type first (functions 
JS_IsNumber/String,/Object/Array), then read out (convert to C types) number, 
string, bool, Array, and Object separately.

To my knowledge there is no function that would do all of this in one go.


-         Guido


From: quickjs-devel-bounce@xxxxxxxxxxxxx 
[mailto:quickjs-devel-bounce@xxxxxxxxxxxxx] On Behalf Of sineysan
Sent: 03 January 2020 08:34
To: quickjs-devel@xxxxxxxxxxxxx
Subject: [quickjs-devel] How to iterate an object in c++ code?

Hello:

I want to iterate a Json object in c++ code, how to do this? I can't find any 
API for this purpose.



Other related posts: