0

I'm using this code to iterate over the properties passed to a native function:

JSObject *iter = JS_NewPropertyIterator(cx, jsargs);
jsid id;
while(JS_NextProperty(cx, iter, &id) && id != JSID_VOID) {
        jsval vp;
        if(!JS_GetPropertyById(cx, jsargs, id, &vp)) {
                continue;
        }
        // ...
}

This works fine to get the value of the property, however, I need the name of that property, too.

I couldn't find any of the various property-related ...ById() functions which give me the property name.

4

1 回答 1

0

Looking at existing code which needs this behavior (the json encoder) helped.

JS_IdToValue is the function I was looking for.

于 2012-05-05T12:06:45.827 回答