Attila Szegedi a écrit :
> The easiest way would be just invoking 
> ScriptRuntime.defaultObjectToSource()
> 
> Other than that, your problem here is that you're converting propid to 
> String. What you should do instead in the loop is:
> 
> ...
> Object propValue;
> if(propid instanceof String) {
>     propValue = ScriptableObject.getProperty(scriptable, (String)propid);
> }
> else if(propid instanceof Number) {
>     propValue = ScriptableObject.getProperty(scriptable, 
> ((Number)propid).intValue());
> }
> else {
>     continue; // or throw an exception
> }
> builder.append(propid);
> builder.append(':');
> builder.append(Context.toString(propValue));
> ...
> 

You can simplify to:
...
Object propValue = ScriptRuntime.getObjectElem(scriptable, propid, context);
builder.append(propid);
builder.append(':');
builder.append(Context.toString(propValue));
...

Christophe
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to