I think you're misunderstanding the API. You have created a program which creates an object "K" in the global context, which you can access via the global object. So, you have to _first_ get the global object, _then_ get K from it, and only _then_ get the properties of K.
So it'll be something like (haven't tested): // Get global object (effectively globalThis) v8::Local<v8::Object> global_obj = context->Global(); // Get K from global object (effectively globalThis["K"]) v8::Local<v8::Object> K_obj = global_obj->Get(context, v8::String::NewFromUtf8(isolate, "K")) // Get the properties from K (effectively Object.keys(globalThis["K"])) v8::Local<Array> arr = K_obj->GetPropertyNames(context); On Thu, Jul 2, 2020 at 4:01 PM <orengavr...@gmail.com> wrote: > What i"m doing wrong ? > > v8::Local<v8::Object> obj = m_Context->Global(); > > 1) Local<Array> arr = obj->GetPropertyNames(m_Context).ToLocalChecked(); > // I got arr->Length = 0 > 2) Local<Array> arr= obj->GetPropertyNames(m_Context, > KeyCollectionMode::kIncludePrototypes, PropertyFilter::ALL_PROPERTIES, > IndexFilter::kSkipIndices).ToLocalChecked(); > // i got 71 items , but none of them are mine > > 3) Local<Value> key =obj->Get(m_Context, > v8::String::NewFromUtf8(m_Isolate, "AA")).ToLocalChecked(); > // i got undefined > > Thanks a lot for all your help > Oren > > On Thursday, July 2, 2020 at 2:57:35 PM UTC+3, Leszek Swirski wrote: >> >> You can access your K object via the context's global object >> <https://v8.github.io/api/head/classv8_1_1Context.html#af5cd9f97ef6a3307c1c21f80f4b743eb>, >> and then iterate it's properties from there. >> >> On Thu, Jul 2, 2020 at 1:47 PM <oreng...@gmail.com> wrote: >> >>> i"m trying to get the variable from context / global without success. >>> >>> Any idea how to do it correctly? >>> >>> >>> On Wednesday, July 1, 2020 at 7:36:48 PM UTC+3, oreng...@gmail.com >>> wrote: >>>> >>>> Thanks, I got you. >>>> Do you know how I retrieve objects from context? >>>> >>>> On Wednesday, July 1, 2020 at 1:31:54 PM UTC+3, Jakob Kummerow wrote: >>>>> >>>>> On Wed, Jul 1, 2020 at 12:13 PM <oreng...@gmail.com> wrote: >>>>> >>>>>> Why do you say its global? >>>>>> >>>>> >>>>> After evaluating the string "const K = {...}", K is a global variable >>>>> in the provided context. >>>>> >>>>> At the sample code, I read the K object from a specific context. >>>>> >>>>> >>>>> No, that's not what you're doing. You're creating an object wrapper >>>>> around a string "K". That object creation needs a context, but that's not >>>>> the same as reading a variable from that context. >>>>> >>>>> -- >>> -- >>> v8-dev mailing list >>> v8-...@googlegroups.com >>> http://groups.google.com/group/v8-dev >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "v8-dev" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to v8-...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/v8-dev/c5187f07-6220-471b-958e-ab12f74bb614o%40googlegroups.com >>> <https://groups.google.com/d/msgid/v8-dev/c5187f07-6220-471b-958e-ab12f74bb614o%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- > -- > v8-dev mailing list > v8-dev@googlegroups.com > http://groups.google.com/group/v8-dev > --- > You received this message because you are subscribed to the Google Groups > "v8-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to v8-dev+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/v8-dev/01ac6bc4-a9fe-493c-8bdc-9cb28998379co%40googlegroups.com > <https://groups.google.com/d/msgid/v8-dev/01ac6bc4-a9fe-493c-8bdc-9cb28998379co%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- -- v8-dev mailing list v8-dev@googlegroups.com http://groups.google.com/group/v8-dev --- You received this message because you are subscribed to the Google Groups "v8-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/CAGRskv_%2BM3Typ7cPAjPhbxQxObMuwN8YmkQL25xU%2Bns%2BD5%2BvfA%40mail.gmail.com.