Creates the Json representation for an invalid controller.

@param description the instance's description
@param json        the json service
@return the json representation
517133
public static JsonNode from(InstanceDescription description, Json json) {
        ObjectNode node = json.newObject();
        node.put("classname", description.getComponentDescription().getName())
                .put("invalid", description.getState() == ComponentInstance.INVALID)
                .put("reason", extractInvalidityReason(description));
        return node;
    }
626209
public RecordedQuery fromJSON(String json) {
		RecordedQuery ret = new RecordedQuery(false);
		StringReader sr = new StringReader(json);
		JsonReader reader = Json.createReader(sr);
		JsonObject jsonResult = reader.readObject();
		
		ret.setGeneric(jsonResult.getBoolean(GENERIC));
		JsonArray augmentations = jsonResult.getJsonArray(AUGMENTATIONS);
		if (augmentations != null) {
			Map<String, String> augs = new HashMap<String, String>();
			Iterator<JsonValue> ait = augmentations.iterator();
			while(ait.hasNext()) {
				JsonObject a = (JsonObject) ait.next();
				augs.put(a.getString(KEY), a.getString(VALUE));
			}
			ret.setAugmentations(augs);
		}
		
		JsonArray statements = jsonResult.getJsonArray(STATEMENTS);
		Iterator<JsonValue> it = statements.iterator();
		while(it.hasNext()) {
			JsonValue s = it.next();
			readStatement(s, ret.getStatements(), ret);
		}
		return ret;
	}
313437
protected final JSON defaultCreateJSON( Map model ) {
      if( skipBindingResult && jsonConfig.getJsonPropertyFilter() == null ){
         this.jsonConfig.setJsonPropertyFilter( new BindingResultPropertyFilter() );
      }
      return JSONSerializer.toJSON( model, jsonConfig );
   }
670647
public Map<String, Object> jsonToMap(String json) {

        /*
         * This if block treats the /v2/accounts/exists response. Currently the endpoint returns the status
         * code on its response body, breaking the JSON conversion.
         */
        if ("200".equals(json)) {
            this.responseBody.put("code", 200);
            return this.responseBody;
        }

        if ("400".equals(json)) {
            this.responseBody.put("code", 400);
            return this.responseBody;
        }

        if ("404".equals(json)) {
            this.responseBody.put("code", 404);
            return this.responseBody;
        }

        if (!json.equals("")) {
            ObjectMapper mapper = new ObjectMapper();
            try {
                this.responseBody = mapper.readValue(json, new TypeReference<Map<String, Object>>(){});
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return this.responseBody;
    }
46446
public static CmsClientAliasImportResult parse(JSONObject json) {

        String line = getString(json, JSON_LINE);
        String message = getString(json, JSON_MESSAGE);
        String statusStr = getString(json, JSON_STATUS);
        CmsAliasImportStatus status = CmsAliasImportStatus.valueOf(statusStr);
        return new CmsClientAliasImportResult(line, status, message);
    }
298431
private JSON getJSON() throws JSONMarshallException {
        if (json == null) {
            JSONSettings settings = new JSONSettings(Include.NON_NULL);
            json = JSONFactory.newInstance(settings);
        }
        return json;
    }
1160848
public static String toJsonStr(JSON json, int indentFactor) {
		if (null == json) {
			return null;
		}
		return json.toJSONString(indentFactor);
	}
409674
public RequestContext renderJSONPretty(final JSONObject json) {
        final JsonRenderer jsonRenderer = new JsonRenderer();
        jsonRenderer.setJSONObject(json);
        jsonRenderer.setPretty(true);

        this.renderer = jsonRenderer;

        return this;
    }
1206471
public static S3Link fromJson(S3ClientCache s3cc, String json) {
        ID id = Jackson.fromJsonString(json, ID.class);
        return new S3Link(s3cc, id);
    }
1345717
protected Article readArticleFromJson(String json) {
        Gson gson = new Gson();
        Article article = gson.fromJson(json, Article.class);
        return article;
    }
16973
@SuppressWarnings({ "rawtypes", "unchecked" })
    private void writeJSON(Object value) throws JSONException {
        if (JSONObject.NULL.equals(value)) {
            write(zipNull, 3);
        } else if (Boolean.FALSE.equals(value)) {
            write(zipFalse, 3);
        } else if (Boolean.TRUE.equals(value)) {
            write(zipTrue, 3);
        } else {
            if (value instanceof Map) {
                value = new JSONObject((Map) value);
            } else if (value instanceof Collection) {
                value = new JSONArray((Collection) value);
            } else if (value.getClass().isArray()) {
                value = new JSONArray(value);
            }
            if (value instanceof JSONObject) {
                write((JSONObject) value);
            } else if (value instanceof JSONArray) {
                write((JSONArray) value);
            } else {
                throw new JSONException("Unrecognized object");
            }
        }
    }
276569
public String buildJson() throws ODataRenderException {
        LOG.debug("Start building Json service root document");
        try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
            JsonGenerator jsonGenerator = JSON_FACTORY.createGenerator(stream, JsonEncoding.UTF8);
            jsonGenerator.writeStartObject();
            jsonGenerator.writeStringField(CONTEXT, getContextURL(uri, entityDataModel));
            jsonGenerator.writeArrayFieldStart(VALUE);


            List<EntitySet> entities = entityDataModel.getEntityContainer().getEntitySets();
            for (EntitySet entity : entities) {
                if (entity.isIncludedInServiceDocument()) {
                    writeObject(jsonGenerator, entity);
                }
            }

            List<Singleton> singletons = entityDataModel.getEntityContainer().getSingletons();
            for (Singleton singleton : singletons) {
                writeObject(jsonGenerator, singleton);
            }

            jsonGenerator.writeEndArray();
            jsonGenerator.writeEndObject();
            jsonGenerator.close();
            return stream.toString(StandardCharsets.UTF_8.name());
        } catch (IOException e) {
            throw new ODataRenderException("It is unable to render service document", e);
        }
    }
52449
public String postJson(String endpoint, JSONObject json) throws IOException {
        return this.postJson(endpoint, "", json);
    }
646726
public static Credentials createFromJson( String json )
    {
        JSONObject jsonObj = ( JSONObject ) new JSONTokener( json ).nextValue();

        if ( jsonObj.has( PasswordCredentials.PASSWORD ) ) {
            // Password credentials
            return PasswordCredentials.fromJson( jsonObj );
        } else {
            // OAuth2 credentials
            return OAuth2Credentials.fromJson( jsonObj );
        }
    }
1249338
public String generateJSON(Collection<Route> routes) {
        Swagger swagger = build(routes);
        String json = Json.pretty(swagger);
        return json;
    }
519334
public static String json(Object obj, boolean writeClass,
                              Converter<Object, Map<String, Object>> mc) throws IOException {
        if (obj == null)
            return NULL;
        StringWriter sw = new StringWriter();
        try {
            json(obj, sw, writeClass, mc);
            return sw.getBuffer().toString();
        } finally {
            sw.close();
        }
    }
1309309
public String toJson(JsonElement jsonElement) {
    StringWriter writer = new StringWriter();
    toJson(jsonElement, writer);
    return writer.toString();
  }