Refine search
public JSON append(final String propName, final boolean value) { object.put(propName, JSONBoolean.getInstance(value)); return this; }
public JSONValue toJsonElement() { JSONObject result = new JSONObject(); JSONValue packVal = JSONBoolean.getInstance(isPack());; result.put("pack", packVal); if (getUri() == null) { setUri((java.lang.String)null); } else { JSONValue uriVal = getUri() == null ? JSONNull.getInstance() : new JSONString(getUri());; result.put("uri", uriVal); } return result; }
@Override public JSONValue encode(Object value) throws JsonEncoderDecoder.EncodingException { if (value instanceof Number) { return new JSONNumber(((Number) value).doubleValue()); } else if (value instanceof Boolean) { return JSONBoolean.getInstance((Boolean) value); } else if (value instanceof Iterable) { JSONArray array = new JSONArray(); int ct = 0; for (Object v : (Iterable<?>) value) { array.set(ct++, encode(v)); } return array; } else if (value instanceof Map) { JSONObject object = new JSONObject(); for (Map.Entry<?, ?> entry : ((Map<?, ?>) value).entrySet()) { object.put(entry.getKey().toString(), encode(entry.getValue())); } return object; } else if (value == null) { return JSONNull.getInstance(); } else { return new JSONString(value.toString()); } }
public JSON append(final String propName, final boolean value) { object.put(propName, JSONBoolean.getInstance(value)); return this; }
@Override public JSONValue encode(Object value) throws JsonEncoderDecoder.EncodingException { if (value instanceof Number) { return new JSONNumber(((Number) value).doubleValue()); } else if (value instanceof Boolean) { return JSONBoolean.getInstance((Boolean) value); } else if (value instanceof Iterable) { JSONArray array = new JSONArray(); int ct = 0; for (Object v : (Iterable<?>) value) { array.set(ct++, encode(v)); } return array; } else if (value instanceof Map) { JSONObject object = new JSONObject(); for (Map.Entry<?, ?> entry : ((Map<?, ?>) value).entrySet()) { object.put(entry.getKey().toString(), encode(entry.getValue())); } return object; } else if (value == null) { return JSONNull.getInstance(); } else { return new JSONString(value.toString()); } }
public JSONValue toJsonElement() { JSONObject result = new JSONObject(); JSONValue showInheritedVal = JSONBoolean.getInstance(getShowInherited());; result.put("showInherited", showInheritedVal); if (getUri() == null) { setUri((java.lang.String)null); } else { JSONValue uriVal = getUri() == null ? JSONNull.getInstance() : new JSONString(getUri());; result.put("uri", uriVal); } return result; }
private JSONValue toJSONArray(LightArray<ContactField> contactField) { JSONArray jsonArray = new JSONArray(); for (int i = 0; i < contactField.length(); i++) { ContactField field = contactField.get(i); JSONObject jsonField = new JSONObject(); jsonField.put(CONTACT_FIELD_TYPE, getAsJSONString(field.getType())); jsonField.put(CONTACT_FIELD_VALUE, getAsJSONString(field.getValue())); jsonField.put(CONTACT_FIELD_PREF, JSONBoolean.getInstance(field.isPref())); jsonArray.set(i, jsonField); } return jsonArray; }
@SuppressWarnings("unchecked") protected static JSONObject encodeMap(Map<String, Object> data) { JSONObject jsobj = new JSONObject(); for (String key : data.keySet()) { Object val = data.get(key); if (val instanceof String) { jsobj.put(key, new JSONString(encodeValue(val))); } else if (val instanceof Date) { jsobj.put(key, new JSONString(encodeValue(val))); } else if (val instanceof Number) { jsobj.put(key, new JSONString(encodeValue(val))); } else if (val instanceof Boolean) { jsobj.put(key, JSONBoolean.getInstance((Boolean) val)); } else if (val == null) { jsobj.put(key, JSONNull.getInstance()); } else if (val instanceof Map) { jsobj.put(key, encodeMap((Map<String, Object>) val)); } else if (val instanceof List) { jsobj.put(key, encodeList((List<Object>) val)); } else if (val instanceof ModelData) { jsobj.put(key, encodeMap(((ModelData) val).getProperties())); } } return jsobj; }
private JSONArray createOrganisation(LightArray<ContactOrganisation> organisations) { JSONArray jsonArray = new JSONArray(); for (int i = 0; i < organisations.length(); i++) { ContactOrganisation co = organisations.get(i); JSONObject orga = new JSONObject(); orga.put(ORGANISATION_NAME, getAsJSONString(co.getName())); orga.put(ORGANISATION_DEPARTMENT, getAsJSONString(co.getDepartment())); orga.put(ORGANISATION_TITLE, getAsJSONString(co.getTitle())); orga.put(ORGANISATION_TYPE,getAsJSONString(co.getType())); orga.put(ORGANISATION_PREF,JSONBoolean.getInstance(co.isPref())); jsonArray.set(i, orga); } return jsonArray; }
@Override public JSONObject toJSONObject() { JSONObject object = super.toJSONObject(); ImageDataFilterChain chain = m_filters; if ((null != chain) && (chain.size() > 0)) { JSONArray filters = new JSONArray(); JSONObject filter = new JSONObject(); filter.put("active", JSONBoolean.getInstance(chain.isActive())); for (ImageDataFilter<?> ifilter : chain.getFilters()) { if (null != ifilter) { JSONObject make = ifilter.toJSONObject(); if (null != make) { filters.set(filters.size(), make); } } } filter.put("filters", filters); object.put("filter", filter); } return object; }
@Override public JSONObject toJSONObject() { final JSONObject object = super.toJSONObject(); final ImageDataFilterChain chain = m_filters; if ((null != chain) && (chain.size() > 0)) { final JSONArray filters = new JSONArray(); final JSONObject filter = new JSONObject(); filter.put("active", JSONBoolean.getInstance(chain.isActive())); for (final ImageDataFilter<?> ifilter : chain.getFilters()) { if (null != ifilter) { final JSONObject make = ifilter.toJSONObject(); if (null != make) { filters.set(filters.size(), make); } } } filter.put("filters", filters); object.put("filter", filter); } return object; }
@Override public JSONObject toJSONObject() { final JSONObject object = super.toJSONObject(); final ImageDataFilterChain chain = m_filters; if ((null != chain) && (chain.size() > 0)) { final JSONArray filters = new JSONArray(); final JSONObject filter = new JSONObject(); filter.put("active", JSONBoolean.getInstance(chain.isActive())); for (final ImageDataFilter<?> ifilter : chain.getFilters()) { if (null != ifilter) { final JSONObject make = ifilter.toJSONObject(); if (null != make) { filters.set(filters.size(), make); } } } filter.put("filters", filters); object.put("filter", filter); } return object; }
JSONValue updateReferencesVal = JSONBoolean.getInstance(isUpdateReferences());; result.put("updateReferences", updateReferencesVal); JSONValue updateQualifiedNamesVal = JSONBoolean.getInstance(isUpdateQualifiedNames());; result.put("updateQualifiedNames", updateQualifiedNamesVal); if (getFilePatterns() == null) { setFilePatterns((java.lang.String)null); result.put("renameParams", renameParamsVal); JSONValue delegateUpdatingVal = JSONBoolean.getInstance(isDelegateUpdating());; result.put("delegateUpdating", delegateUpdatingVal); JSONValue deprecateDelegatesVal = JSONBoolean.getInstance(isDeprecateDelegates());; result.put("deprecateDelegates", deprecateDelegatesVal); JSONValue updateSubpackagesVal = JSONBoolean.getInstance(isUpdateSubpackages());; result.put("updateSubpackages", updateSubpackagesVal); JSONValue updateSimilarDeclarationsVal = JSONBoolean.getInstance(isUpdateSimilarDeclarations());; result.put("updateSimilarDeclarations", updateSimilarDeclarationsVal); if (getMatchStrategy() == null) { result.put("matchStrategy", matchStrategyVal); JSONValue updateTextualMatchesVal = JSONBoolean.getInstance(isUpdateTextualMatches());; result.put("updateTextualMatches", updateTextualMatchesVal); return result;
@Override public JSONObject toJSONObject() { final JSONObject object = super.toJSONObject(); final ImageDataFilterChain chain = m_filters; if ((null != chain) && (chain.size() > 0)) { final JSONArray filters = new JSONArray(); final JSONObject filter = new JSONObject(); filter.put("active", JSONBoolean.getInstance(chain.isActive())); for (final ImageDataFilter<?> ifilter : chain.getFilters()) { if (null != ifilter) { final JSONObject make = ifilter.toJSONObject(); if (null != make) { filters.set(filters.size(), make); } } } filter.put("filters", filters); object.put("filter", filter); } return object; }
private JSONArray createAddresses(LightArray<ContactAddress> addresses) { JSONArray jsonArray = new JSONArray(); for (int i = 0; i < addresses.length(); i++) { ContactAddress contactAddress = addresses.get(i); JSONObject address = new JSONObject(); address.put(ADDRESS_FORMATTED, getAsJSONString(contactAddress.getFormatted())); address.put(ADDRESS_STREET_ADDRESS, getAsJSONString(contactAddress.getStreetAddress())); address.put(ADDRESS_LOCALITY, getAsJSONString(contactAddress.getLocality())); address.put(ADDRESS_REGION, getAsJSONString(contactAddress.getRegion())); address.put(ADDRESS_POSTAL_CODE, getAsJSONString(contactAddress.getPostalCode())); address.put(ADDRESS_COUNTRY, getAsJSONString(contactAddress.getCountry())); address.put(ADDRESS_TYPE, getAsJSONString(contactAddress.getType())); address.put(ADDRESS_PREF, JSONBoolean.getInstance(contactAddress.isPref())); jsonArray.set(i, address); } return jsonArray; }
public JSONValue toJsonElement() { JSONObject result = new JSONObject(); if (getDestination() == null) { setDestination((java.lang.String)null); } else { JSONValue destinationVal = getDestination() == null ? JSONNull.getInstance() : new JSONString(getDestination());; result.put("destination", destinationVal); } if (getElements() == null) { setElements((java.util.List<org.eclipse.che.jdt.ls.extension.api.dto.Resource>)null); } else { JSONArray elementsVal = new JSONArray(); for (org.eclipse.che.jdt.ls.extension.api.dto.Resource elementsValX : getElements()) { JSONValue elementsValY = elementsValX == null ? JSONNull.getInstance() : ((ResourceDto)elementsValX).toJsonElement();; elementsVal.set(elementsVal.size(), elementsValY); } result.put("elements", elementsVal); } JSONValue updateReferencesVal = JSONBoolean.getInstance(isUpdateReferences());; result.put("updateReferences", updateReferencesVal); JSONValue updateQualifiedNamesVal = JSONBoolean.getInstance(isUpdateQualifiedNames());; result.put("updateQualifiedNames", updateQualifiedNamesVal); if (getFilePatterns() == null) { setFilePatterns((java.lang.String)null); } else { JSONValue filePatternsVal = getFilePatterns() == null ? JSONNull.getInstance() : new JSONString(getFilePatterns());; result.put("filePatterns", filePatternsVal); } return result; }
public JSONObject toJSONObject() JSONObject attr = new JSONObject(getAttributes().getJSO()); attr.put("url", new JSONString(url)); attr.put("url", new JSONString(toDataURL(DataURLType.PNG, false))); JSONObject object = new JSONObject(); object.put("type", new JSONString(getShapeType().getValue())); object.put("meta", new JSONObject(getMetaData().getJSO())); object.put("attributes", attr); JSONObject filter = new JSONObject(); filter.put("active", JSONBoolean.getInstance(chain.isActive()));
public JSONObject toJSONObject() final JSONObject attr = new JSONObject(getAttributes().getJSO()); attr.put("url", new JSONString(url)); attr.put("url", new JSONString(toDataURL(false))); final JSONObject object = new JSONObject(); object.put("type", new JSONString(getShapeType().getValue())); object.put("meta", new JSONObject(meta.getJSO())); final JSONObject filter = new JSONObject(); filter.put("active", JSONBoolean.getInstance(chain.isActive()));
public JSONObject toJSONObject() final JSONObject attr = new JSONObject(getAttributes().getJSO()); attr.put("url", new JSONString(url)); attr.put("url", new JSONString(toDataURL(false))); final JSONObject object = new JSONObject(); object.put("type", new JSONString(getShapeType().getValue())); object.put("meta", new JSONObject(meta.getJSO())); final JSONObject filter = new JSONObject(); filter.put("active", JSONBoolean.getInstance(chain.isActive()));
public void testReadListFromJSONObjectWithNonExistingArray() { JSONObject json = null; List<Amoeba> amoebas = null; json = new JSONObject(); json.put("foo", JSONNull.getInstance()); amoebas = Amoeba.JSON_READER.readList(json); assertNull(amoebas); json = new JSONObject(); json.put("foo", new JSONNumber(123)); amoebas = Amoeba.JSON_READER.readList(json); assertNull(amoebas); json = new JSONObject(); json.put("foo", JSONBoolean.getInstance(false)); amoebas = Amoeba.JSON_READER.readList(json); assertNull(amoebas); json = new JSONObject(); json.put("foo", new JSONObject()); amoebas = Amoeba.JSON_READER.readList(json); assertNull(amoebas); }