@Override public String readString(String name) { if (current == null || !(current instanceof JSONObject)) { return null; } JSONObject object = ((JSONObject)current); JSONValue value = object.get(name); if (value == null || (value.isNull() instanceof JSONNull)) { return null; } JSONString stringValue = value.isString(); if (stringValue == null) { return null; } return stringValue.stringValue(); }
@Override public Long decode(JSONValue value) throws DecodingException { if (value == null || value.isNull() != null) { return null; } JSONString valueString = value.isString(); if (valueString != null) { return Long.parseLong(valueString.stringValue()); } return (long) toDouble(value); }
/** * Get a child JSON object from a parent JSON object. * * @param jsonObject The parent JSON object. * @param key The name of the child object. * @return Returns the child JSON object if it could be found, or null if the value was null. * @throws JSONException In case something went wrong while searching for the child. */ public static JSONObject getChild(JSONObject jsonObject, String key) throws JSONException { checkArguments(jsonObject, key); JSONValue value = jsonObject.get(key); if (value != null) { if (value.isObject() != null) { return value.isObject(); } else if (value.isNull() != null) { return null; } throw new JSONException("Child is not a JSONObject, but a: " + value.getClass()); } return null; }
protected <Y> void parseSingularJsonReference( X targetEntity, ErraiSingularAttribute<? super X, Y> attr, JSONValue attrJsonValue, ErraiEntityManager eem) { if (attrJsonValue == null || attrJsonValue.isNull() != null) return; Key<Y, ?> key = (Key<Y, ?>) Key.fromJsonObject(eem, attrJsonValue.isObject(), true); logger.trace(" looking for " + key); Y value = eem.find(key, Collections.<String,Object>emptyMap()); attr.set(targetEntity, value); }
public static YamlDTOImpl fromJsonObjectInt(JSONValue jsonValue, boolean copyJsons) { if (jsonValue == null || jsonValue.isNull() != null) { return null; } YamlDTOImpl dto = new YamlDTOImpl(); JSONObject json = jsonValue.isObject(); if (json.containsKey("schemas")) { JSONValue schemasIn = json.get("schemas"); java.util.Map<java.lang.String, java.lang.String> schemasOut = null; if (schemasIn != null && schemasIn.isNull() == null) { schemasOut = new java.util.HashMap<java.lang.String, java.lang.String>(); java.util.Set<String> keySet0 = schemasIn.isObject().keySet(); for (String key0 : keySet0) { JSONValue schemasIn_ = schemasIn.isObject().get(key0); String schemasOut_ = schemasIn_.isString() != null ? schemasIn_.isString().stringValue() : null; schemasOut.put(key0, schemasOut_); } } dto.setSchemas(schemasOut); } return dto; }
@Override public Long decode(JSONValue value) throws DecodingException { if (value == null || value.isNull() != null) { return null; } JSONString valueString = value.isString(); if (valueString != null) { return Long.parseLong(valueString.stringValue()); } return (long) toDouble(value); }
public static RefactoringResultDto fromJson(JSONValue jsonVal) { if (jsonVal == null) { return null; } JSONObject json= jsonVal.isObject(); RefactoringResultDto result= new RefactoringResultDto(); JSONValue jsonrefactoringStatusJson = json.get("refactoringStatus"); if (jsonrefactoringStatusJson != null && !(jsonrefactoringStatusJson.isNull() != null)) { org.eclipse.che.jdt.ls.extension.api.dto.RefactoringStatus jsonrefactoringStatusVal = RefactoringStatusDto.fromJson((JSONObject)jsonrefactoringStatusJson);; result.setRefactoringStatus((org.eclipse.che.jdt.ls.extension.api.dto.RefactoringStatus)jsonrefactoringStatusVal); } JSONValue jsoncheWorkspaceEditJson = json.get("cheWorkspaceEdit"); if (jsoncheWorkspaceEditJson != null && !(jsoncheWorkspaceEditJson.isNull() != null)) { org.eclipse.che.jdt.ls.extension.api.dto.CheWorkspaceEdit jsoncheWorkspaceEditVal = CheWorkspaceEditDto.fromJson((JSONObject)jsoncheWorkspaceEditJson);; result.setCheWorkspaceEdit((org.eclipse.che.jdt.ls.extension.api.dto.CheWorkspaceEdit)jsoncheWorkspaceEditVal); } return result; } }
public static JarDto fromJson(JSONValue jsonVal) { if (jsonVal == null) { return null; } JSONObject json= jsonVal.isObject(); JarDto result= new JarDto(); JSONValue jsonidJson = json.get("id"); if (jsonidJson != null && !(jsonidJson.isNull() != null)) { java.lang.String jsonidVal = jsonidJson.isString().stringValue();; result.setId((java.lang.String)jsonidVal); } JSONValue jsonnameJson = json.get("name"); if (jsonnameJson != null && !(jsonnameJson.isNull() != null)) { java.lang.String jsonnameVal = jsonnameJson.isString().stringValue();; result.setName((java.lang.String)jsonnameVal); } return result; } }
@Override public Document decode(JSONValue value) throws DecodingException { if (value == null || value.isNull() != null) { return null; } JSONString str = value.isString(); if (str == null) { throw new DecodingException("Expected a json string, but was given: " + value); } return XMLParser.parse(str.stringValue()); }
@Override public Map<K, V> deserialize(final JSONValue jsonValue) { if (jsonValue == null || jsonValue.isNull() != null) { return null; } final JSONObject jsonObject = jsonValue.isObject(); if (jsonObject == null) { throw new GWTPojoSerializerException("Unable to deserialize " + jsonValue.toString() + " as Map<?, ?>"); } final Map<K, V> map = new HashMap<K, V>(); for (String keyString : jsonObject.keySet()) { final K key = kSerializer.deserialize(new JSONString(keyString)); final V value = vSerializer.deserialize(jsonObject.get(keyString)); map.put(key, value); } return map; } }
/** * checks if a certain object value is null. * * @param jsonObject The object to get the key value from. * @param key The name of the key to search the value for. * @throws JSONException In case something went wrong while parsing. */ public static boolean isNullObject(JSONObject jsonObject, String key) throws JSONException { checkArguments(jsonObject, key); JSONValue value = jsonObject.get(key); boolean isNull = false; if (value == null || value.isNull() != null) { isNull = true; } return isNull; }
public static StatusReportDto fromJson(JSONValue jsonVal) { if (jsonVal == null) { return null; } JSONObject json= jsonVal.isObject(); StatusReportDto result= new StatusReportDto(); JSONValue jsontypeJson = json.get("type"); if (jsontypeJson != null && !(jsontypeJson.isNull() != null)) { java.lang.String jsontypeVal = jsontypeJson.isString().stringValue();; result.setType((java.lang.String)jsontypeVal); } JSONValue jsonmessageJson = json.get("message"); if (jsonmessageJson != null && !(jsonmessageJson.isNull() != null)) { java.lang.String jsonmessageVal = jsonmessageJson.isString().stringValue();; result.setMessage((java.lang.String)jsonmessageVal); } return result; } }
@Override public Document decode(JSONValue value) throws DecodingException { if (value == null || value.isNull() != null) { return null; } JSONString str = value.isString(); if (str == null) { throw new DecodingException("Expected a json string, but was given: " + value); } return XMLParser.parse(str.stringValue()); }
return null; JSONObject json= jsonVal.isObject(); CheWorkspaceEditDto result= new CheWorkspaceEditDto(); JSONValue jsoncheResourceChangesJson = json.get("cheResourceChanges"); if (jsoncheResourceChangesJson != null && !(jsoncheResourceChangesJson.isNull() != null)) { ArrayList<org.eclipse.che.jdt.ls.extension.api.dto.CheResourceChange> jsoncheResourceChangesVal= new ArrayList<org.eclipse.che.jdt.ls.extension.api.dto.CheResourceChange>(); JSONArray jsoncheResourceChangesVala = jsoncheResourceChangesJson.isArray(); JSONValue jsonchangesJson = json.get("changes"); if (jsonchangesJson != null && !(jsonchangesJson.isNull() != null)) { java.util.Map<java.lang.String, java.util.List<org.eclipse.lsp4j.TextEdit>> jsonchangesVal= new HashMap<String, java.util.List<org.eclipse.lsp4j.TextEdit>>(); JSONObject jsonchangesValo = jsonchangesJson.isObject(); for(String jsonchangesValok : jsonchangesValo.keySet()) { ArrayList<org.eclipse.lsp4j.TextEdit> jsonchangesValoX= new ArrayList<org.eclipse.lsp4j.TextEdit>(); JSONArray jsonchangesValoXa = jsonchangesValo.get(jsonchangesValok).isArray(); for(int jsonchangesValoXai= 0; jsonchangesValoXai < jsonchangesValoXa.size(); jsonchangesValoXai++) { org.eclipse.lsp4j.TextEdit jsonchangesValoXaX = TextEditDto.fromJson((JSONObject)jsonchangesValoXa.get(jsonchangesValoXai));; JSONValue jsondocumentChangesJson = json.get("documentChanges"); if (jsondocumentChangesJson != null && !(jsondocumentChangesJson.isNull() != null)) { ArrayList<org.eclipse.lsp4j.jsonrpc.messages.Either<org.eclipse.lsp4j.TextDocumentEdit, org.eclipse.lsp4j.ResourceOperation>> jsondocumentChangesVal= new ArrayList<org.eclipse.lsp4j.jsonrpc.messages.Either<org.eclipse.lsp4j.TextDocumentEdit, org.eclipse.lsp4j.ResourceOperation>>(); JSONArray jsondocumentChangesVala = jsondocumentChangesJson.isArray(); JSONValue jsonresourceChangesJson = json.get("resourceChanges"); if (jsonresourceChangesJson != null && !(jsonresourceChangesJson.isNull() != null)) { ArrayList<org.eclipse.lsp4j.jsonrpc.messages.Either<org.eclipse.lsp4j.ResourceChange, org.eclipse.lsp4j.TextDocumentEdit>> jsonresourceChangesVal= new ArrayList<org.eclipse.lsp4j.jsonrpc.messages.Either<org.eclipse.lsp4j.ResourceChange, org.eclipse.lsp4j.TextDocumentEdit>>(); JSONArray jsonresourceChangesVala = jsonresourceChangesJson.isArray();
/** * Get a child JSON array from a parent JSON object. * * @param jsonObject The parent JSON object. * @param key The name of the child object. * @return Returns the child JSON array if it could be found, or null if the value was null. * @throws JSONException In case something went wrong while searching for the child. */ public static JSONArray getChildArray(JSONObject jsonObject, String key) throws JSONException { checkArguments(jsonObject, key); JSONValue value = jsonObject.get(key); if (value != null) { if (value.isArray() != null) { return value.isArray(); } else if (value.isNull() != null) { return null; } throw new JSONException("Child is not a JSONArray, but a: " + value.getClass()); } return null; }
public static ResourceLocationDto fromJson(JSONValue jsonVal) { if (jsonVal == null) { return null; } JSONObject json= jsonVal.isObject(); ResourceLocationDto result= new ResourceLocationDto(); JSONValue jsonlibIdJson = json.get("libId"); if (jsonlibIdJson != null && !(jsonlibIdJson.isNull() != null)) { java.lang.String jsonlibIdVal = jsonlibIdJson.isString().stringValue();; result.setLibId((java.lang.String)jsonlibIdVal); } JSONValue jsonfqnJson = json.get("fqn"); if (jsonfqnJson != null && !(jsonfqnJson.isNull() != null)) { java.lang.String jsonfqnVal = jsonfqnJson.isString().stringValue();; result.setFqn((java.lang.String)jsonfqnVal); } return result; } }
@Override public Character deserialize(final JSONValue jsonValue) { if (jsonValue == null || jsonValue.isNull() != null) { return null; } final JSONString jsonString = jsonValue.isString(); if (jsonString != null) { if (jsonString.stringValue().isEmpty()) { return null; } if (jsonString.stringValue().length() == 1) { return jsonString.stringValue().charAt(0); } } throw new GWTPojoSerializerException("Unable to deserialize " + jsonValue.toString() + " as character"); } }