views:

113

answers:

1

Hi guys. I am using a Javascript object as an object with configuration properties. E.g. I have this object in javascript:

var myProps = {prop1: 'prop1', prop2: 'prop2', 'prop3': 'prop3'};

This object (NativeObject) is returned to me in Java function. E.g.

public Static void jsStaticFunction_test(NativeObject obj) {
    //work with object here
}

I want to get all properties from object and build HashMap from it.

Any help will be appreciated.

+1  A: 

So, I solved my problem :)

Code:

public static void jsStaticFunction_test(NativeObject obj) {
    HashMap<String, String> mapParams = new HashMap<String, String>();

    if(obj != null) {
        Object[] propIds = NativeObject.getPropertyIds(obj);
        for(Object propId: propIds) {
            String key = propId.toString();
            String value = NativeObject.getProperty(obj, key).toString();
            mapParams.put(key, value);
        }
    }
    //work with mapParams next..
}
Vitaly Dyatlov