decode a json-encoded action.
@param in the action to decode
@return the resulting action
@throws JSONConverterException if the conversion failed
429840
public Action fromJSON(JSONObject in) throws JSONConverterException {
        String id = requiredString(in, ACTION_ID_LABEL);
        Action a;

        switch (id) {
            case "bootVM":
                a = bootVMFromJSON(in);
                break;
            case "shutdownVM":
                a = shutdownVMFromJSON(in);
                break;
            case "shutdownNode":
                a = shutdownNodeFromJSON(in);
                break;
            case "bootNode":
                a = bootNodeFromJSON(in);
                break;
            case "forgeVM":
                a = forgeVMFromJSON(in);
                break;
            case "killVM":
                a = killVMFromJSON(in);
                break;
            case "migrateVM":
                a = migrateVMFromJSON(in);
                break;
            case "resumeVM":
                a = resumeVMFromJSON(in);
                break;
            case "suspendVM":
                a = suspendVMFromJSON(in);
                break;
            case RC_ALLOCATE_LABEL:
                a = allocateFromJSON(in);
                break;
            default:
                throw new JSONConverterException("Unsupported action '" + id + "'");
        }

        attachEvents(a, in);
        return a;
    }
528681
private JsonConvertOptions getJsonConverterOptions(JsonMBean pAnno) {
        // Extract conversion options from the annotation
        if (pAnno == null) {
            return JsonConvertOptions.DEFAULT;
        } else {
            ValueFaultHandler faultHandler =
                    pAnno.faultHandling() == JsonMBean.FaultHandler.IGNORE_ERRORS ?
                            ValueFaultHandler.IGNORING_VALUE_FAULT_HANDLER :
                            ValueFaultHandler.THROWING_VALUE_FAULT_HANDLER;
            return new JsonConvertOptions.Builder()
                    .maxCollectionSize(pAnno.maxCollectionSize())
                    .maxDepth(pAnno.maxDepth())
                    .maxObjects(pAnno.maxObjects())
                    .faultHandler(faultHandler)
                    .build();
        }
    }
1027449
private String decode(PdfString in) {
		byte[] bytes = in.getBytes();
		return gs().font.decode(bytes, 0, bytes.length);
	}
884089
public JsonResponse apiGet(ApiAction action, Map<String, Object> data) throws IOException {
        return httpRequestJson(action, HttpRequestMethod.GET, data);
    }
842768
protected Object jsonDeserialize(byte[] in, Class<?> cls) {
        if (in == null || in.length == 0) {
            return null;
        }
        Object res = null;
        try {
            res = JsonUtils.json2Object(new String(in, "utf-8"), cls);
        } catch (UnsupportedEncodingException e) {
            logger.error("DeSerialize object fail ", e);
        }
        return res;
    }
424435
private static <T> T jsonDecode(String responseContent, TypeReference<T> valueTypeRef) throws IOException {

      ObjectMapper mapper = new ObjectMapper();
      
      try {
         return mapper.<T>readValue(responseContent, valueTypeRef);
      } catch (JsonGenerationException e) {
         logger.severe("unable decode");
         throw new IOException(e);
      } catch (JsonMappingException e) {
         logger.severe("unable decode");
         throw new IOException(e.getMessage());
      }
   }
71166
@Override
	public ActionInvocation deserialize(ActionContext actionContext) {
		JsonActionInvocation that = this;
		that.container = actionContext.getContainer();
		return that;
	}
544135
private static void decode(InputStream in, StringBuilder result) throws ApiDataException, ApiConnectionException {
        try {
            int len = readLen(in);
            if (len > 0) {
                byte buf[] = new byte[len];
                for (int i = 0; i < len; ++i) {
                    int c = in.read();
                    if (c < 0) {
                        throw new ApiDataException("Truncated data. Expected to read more bytes");
                    }
                    buf[i] = (byte) (c & 0xFF);
                }
                String res = new String(buf, Charset.forName("UTF-8"));
                if (result.length() > 0) {
                    result.append("\n");
                }
                result.append(res);
                decode(in, result);
            }
        } catch (IOException ex) {
            throw new ApiConnectionException(ex.getMessage(), ex);
        }
    }
28558
public JSONObject toJSON(ModelView o) throws JSONConverterException {
        ModelViewConverter c = java2json.get(o.getClass());
        if (c == null) {
            throw new JSONConverterException("No converter available for a view with the '" + o.getClass() + "' className");
        }
        return c.toJSON(o);
    }
484122
public static Expression decodeJson(JsonObject json) {
        char[] encoded = JsonStringEncoder.getInstance().quoteAsString(json.toString());
        return x("DECODE_JSON(\"" + new String(encoded) + "\")");
    }
1177407
function stringify(data, action) {
  try {
    return JSON.stringify(data);
  }
  catch (ex) {
    console.error('Performing "' + action + '". Failed to stringify', data);
    util.errorHandler(ex);

    data = {
      code: -1,
      data: ex.toString()
    };
    return JSON.stringify(data);
  }
}
439360
function decode(callback) {
    if (typeof callback == 'function') {
      return callback;
    } else {
      var split = callback.split('::');
      var action = split[0];
      var method = split[1] || 'index';
      return {
        action: action,
        method: method,
        arguments: []
      };
    }
  }
431895
public List<SatConstraint> listFromJSON(Model mo, JSONArray in) throws JSONConverterException {
        List<SatConstraint> l = new ArrayList<>(in.size());
        for (Object o : in) {
            if (!(o instanceof JSONObject)) {
                throw new JSONConverterException("Expected an array of JSONObject but got an array of " + o.getClass().getName());
            }
            l.add((SatConstraint) fromJSON(mo, (JSONObject) o));
        }
        return l;
    }
376170
public <T> T parse(String in, Class<T> mapTo) throws ParseException {
		return getPString().parse(in, JSONValue.defaultReader.getMapper(mapTo));
	}
271043
public static <T> T parseWithException(String in, Class<T> mapTo) throws ParseException {
		JSONParser p = new JSONParser(DEFAULT_PERMISSIVE_MODE);
		return p.parse(in, defaultReader.getMapper(mapTo));
	}
1249536
public static function decode($json)
    {
        $object = json_decode($json, true);
        if (json_last_error() !== JSON_ERROR_NONE) {
            $error = 'JSON error';
            if (function_exists('json_last_error_msg')) {
                $error = json_last_error_msg();
            } else { // @codeCoverageIgnoreStart
                switch (json_last_error()) {
                    case JSON_ERROR_DEPTH:
                        $error = 'maximum stack depth exceeded';
                        break;
                    case JSON_ERROR_STATE_MISMATCH:
                        $error = 'invalid or malformed JSON';
                        break;
                    case JSON_ERROR_CTRL_CHAR:
                        $error = 'control character error';
                        break;
                    case JSON_ERROR_SYNTAX:
                        $error = 'JSON syntax error';
                        break;
                    case JSON_ERROR_UTF8:
                        $error = 'malformed UTF-8 characters';
                        break;
                }
            } // @codeCoverageIgnoreEnd
            throw new JsonException($error);
        }
        return $object;
    }
776508
function parseAction ({ action, payload={}, error=false }) {
  switch (typeof action) {
    // If it's an action creator, create the action
    case 'function': return action(payload)
    // If it's an action object return the action
    case 'object': return action
    // Otherwise, create a "default" action object with the given type
    case 'string': return { type: action, payload, error }
    default: throw new Error('Invalid action definition (must be function, object or string).')
  }
}