org.mozilla.javascript.NativeJSON Java Examples

The following examples show how to use org.mozilla.javascript.NativeJSON. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScriptedIncomingMapping.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
private Adaptable getAdaptableFromObject(final Context cx, final Object result) {
    final String dittoProtocolJsonStr = (String) NativeJSON.stringify(cx, scope, result, null, null);

    return DittoJsonException.wrapJsonRuntimeException(() -> {
        final JsonObject jsonObject = JsonFactory.readFrom(dittoProtocolJsonStr).asObject();
        return ProtocolFactory.jsonifiableAdaptableFromJson(jsonObject);
    });
}
 
Example #2
Source File: DetermineBasalAdapterSMBJS.java    From AndroidAPS with GNU Affero General Public License v3.0 4 votes vote down vote up
private Object makeParamArray(JSONArray jsonArray, Context rhino, Scriptable scope) {
    //Object param = NativeJSON.parse(rhino, scope, "{myarray: " + jsonArray.toString() + " }", new Callable() {
    Object param = NativeJSON.parse(rhino, scope, jsonArray.toString(), (context, scriptable, scriptable1, objects) -> objects[1]);
    return param;
}
 
Example #3
Source File: DetermineBasalAdapterAMAJS.java    From AndroidAPS with GNU Affero General Public License v3.0 4 votes vote down vote up
private Object makeParamArray(JSONArray jsonArray, Context rhino, Scriptable scope) {
    //Object param = NativeJSON.parse(rhino, scope, "{myarray: " + jsonArray.toString() + " }", new Callable() {
    Object param = NativeJSON.parse(rhino, scope, jsonArray.toString(), (context, scriptable, scriptable1, objects) -> objects[1]);
    return param;
}
 
Example #4
Source File: DetermineBasalAdapterMAJS.java    From AndroidAPS with GNU Affero General Public License v3.0 4 votes vote down vote up
private Object makeParam(JSONObject jsonObject, Context rhino, Scriptable scope) {
    Object param = NativeJSON.parse(rhino, scope, jsonObject.toString(), (context, scriptable, scriptable1, objects) -> objects[1]);
    return param;
}
 
Example #5
Source File: RhinoJsonToString.java    From elasticshell with Apache License 2.0 4 votes vote down vote up
@Override
public String jsonToString(NativeObject json, boolean prettify) {
    Context context = Context.getCurrentContext();
    Object jsonString = NativeJSON.stringify(context, ScriptRuntime.getGlobal(context), json, null, prettify ? "  " : null);
    return jsonString.toString();
}
 
Example #6
Source File: DetermineBasalAdapterSMBJS.java    From AndroidAPS with GNU Affero General Public License v3.0 3 votes vote down vote up
private Object makeParam(JSONObject jsonObject, Context rhino, Scriptable scope) {

        if (jsonObject == null) return Undefined.instance;

        Object param = NativeJSON.parse(rhino, scope, jsonObject.toString(), (context, scriptable, scriptable1, objects) -> objects[1]);
        return param;
    }
 
Example #7
Source File: DetermineBasalAdapterAMAJS.java    From AndroidAPS with GNU Affero General Public License v3.0 3 votes vote down vote up
private Object makeParam(JSONObject jsonObject, Context rhino, Scriptable scope) {

        if (jsonObject == null) return Undefined.instance;

        Object param = NativeJSON.parse(rhino, scope, jsonObject.toString(), (context, scriptable, scriptable1, objects) -> objects[1]);
        return param;
    }