Example usage for jdk.nashorn.internal.runtime JSONFunctions parse

List of usage examples for jdk.nashorn.internal.runtime JSONFunctions parse

Introduction

In this page you can find the example usage for jdk.nashorn.internal.runtime JSONFunctions parse.

Prototype

public static Object parse(final Object text, final Object reviver) 

Source Link

Document

Parses the given JSON text string and returns object representation.

Usage

From source file:Runner.Contact.java

public Object queryActionRule(ScriptObjectMirror mirror) throws IOException {

    String responseFileName = "";

    switch ((String) mirror.get("lifecycle")) {
    case "Create":
        responseFileName = "queryActionCreateResponse.json";
        break;/* w  w w .  j a  v  a  2s  .c o  m*/
    case "Ack":
        responseFileName = "queryActionAckResponse.json";
        break;
    case "Resolve":
        responseFileName = "queryActionResolveResponse.json";
        break;
    }

    String responseFile = System.getProperty("user.dir") + System.getProperty("file.separator") + "src"
            + System.getProperty("file.separator") + "jsFiles" + System.getProperty("file.separator")
            + responseFileName;

    String content = new String(Files.readAllBytes(Paths.get(responseFile)), "UTF-8");
    return JSONFunctions.parse(content, mirror);
}

From source file:Runner.Contact.java

public Object queryDispatchMapWithNextAvailableUser(ScriptObjectMirror mirror) throws IOException {

    String responseFileName = "queryDM" + (String) mirror.get("lifecycle") + "Response.json";

    String responseFile = System.getProperty("user.dir") + System.getProperty("file.separator") + "src"
            + System.getProperty("file.separator") + "jsFiles" + System.getProperty("file.separator")
            + responseFileName;/*from   w ww .j  av  a2s  .  co  m*/

    String content = new String(Files.readAllBytes(Paths.get(responseFile)), "UTF-8");
    return JSONFunctions.parse(content, mirror);
}