Create a ParameterAveragingTrainingMaster instance by deserializing a JSON string that has been serialized with
{@link #toJson()}

@param jsonStr ParameterAveragingTrainingMaster configuration serialized as JSON
974185
public static ParameterAveragingTrainingMaster fromJson(String jsonStr) {
        ObjectMapper om = getJsonMapper();
        try {
            return om.readValue(jsonStr, ParameterAveragingTrainingMaster.class);
        } catch (IOException e) {
            throw new RuntimeException("Could not parse JSON", e);
        }
    }
1009797
public static ParameterAveragingTrainingMaster fromYaml(String yamlStr) {
        ObjectMapper om = getYamlMapper();
        try {
            return om.readValue(yamlStr, ParameterAveragingTrainingMaster.class);
        } catch (IOException e) {
            throw new RuntimeException("Could not parse YAML", e);
        }
    }
130493
public static org.tensorflow.framework.ConfigProto fromJson(String json) {
        org.tensorflow.framework.ConfigProto.Builder builder = org.tensorflow.framework.ConfigProto.newBuilder();
        try {
            JsonFormat.parser().merge(json,builder);
            org.tensorflow.framework.ConfigProto build = builder.build();
            ByteString serialized = build.toByteString();
            byte[] binaryString = serialized.toByteArray();
            org.tensorflow.framework.ConfigProto configProto = org.tensorflow.framework.ConfigProto.parseFrom(binaryString);
            return configProto;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }
1368437
@Override
    public void toJSONString(JSONStringer stringer) throws JSONException
    {
        super.toJSONString(stringer);

        stringer.key("partitionRanges").object();

        for (PartitionRanges partitionRange : partitionRanges) {
            stringer.key(Integer.toString(partitionRange.partitionId)).object();

            for (Map.Entry<Integer, Integer> rangeEntry : partitionRange.ranges.entrySet()) {
                stringer.key(rangeEntry.getKey().toString()).value(rangeEntry.getValue());
            }

            stringer.endObject();
        }

        stringer.endObject();
    }
1276118
public static <T> T loadJsonToBean(String jsonPath, String encoding, Class<T> clazz) throws IOException {
        JSONObject jsonObject = JSONObject.parseObject(FileExecutor.readFileToString(new File(jsonPath), encoding));
        return JSONObject.toJavaObject(jsonObject, clazz);
    }
1265816
public String writeRawJson(final String json, final String contextUrl) throws ODataRenderException {
        this.contextURL = checkNotNull(contextUrl);
        try {
            final ByteArrayOutputStream stream = new ByteArrayOutputStream();
            jsonGenerator = JSON_FACTORY.createGenerator(stream, JsonEncoding.UTF8);
            jsonGenerator.writeRaw(json);
            jsonGenerator.close();
            return stream.toString(StandardCharsets.UTF_8.name());
        } catch (final IOException e) {
            throw new ODataRenderException("Not possible to write raw json to stream JSON: ", e);
        }
    }
19630
void toJSONString(final Map<ReferenceEqualityKey<JSONReference>, CharSequence> jsonReferenceToId,
            final boolean includeNullValuedFields, final int depth, final int indentWidth,
            final StringBuilder buf) {
        final boolean prettyPrint = indentWidth > 0;
        final int n = items.size();
        if (n == 0) {
            buf.append("[]");
        } else {
            buf.append('[');
            if (prettyPrint) {
                buf.append('\n');
            }
            for (int i = 0; i < n; i++) {
                final Object item = items.get(i);
                if (prettyPrint) {
                    JSONUtils.indent(depth + 1, indentWidth, buf);
                }
                JSONSerializer.jsonValToJSONString(item, jsonReferenceToId, includeNullValuedFields, depth + 1,
                        indentWidth, buf);
                if (i < n - 1) {
                    buf.append(',');
                }
                if (prettyPrint) {
                    buf.append('\n');
                }
            }
            if (prettyPrint) {
                JSONUtils.indent(depth, indentWidth, buf);
            }
            buf.append(']');
        }
    }
674245
public void setJsonFactory(IJsonFactory jsonFactory) {
		if (jsonFactory == null) {
			throw new IllegalArgumentException("jsonFactory can not be null.");
		}
		JsonManager.me().setDefaultJsonFactory(jsonFactory);
	}
543450
public static <T> T fromJsonString(String jsonString, Class<T> clazz, ClassLoader classLoader) {
        if (jsonString == null) {
            return null;
        }
        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
        if (classLoader != null) {
            Thread.currentThread().setContextClassLoader(classLoader);
        }
        try {
            ObjectMapper mapper = poolMapper.borrowObject();
            if (mapper != null) {
                try {
                    return mapper.readValue(jsonString, clazz);
                } finally {
                    poolMapper.returnObject(mapper);
                }
            }
            throw new DeserializationException("No ObjectMapper instance avaialble!");
        } catch (Exception e) {
            throw e instanceof DeserializationException ? (DeserializationException) e
                    : new DeserializationException(e);
        } finally {
            Thread.currentThread().setContextClassLoader(oldClassLoader);
        }
    }
1367833
private char retrieveWrappingQuoteTypeOfJsonMemberNames(String jsonString) {
        char quote = '\"';   //  the default quote character used to specify json member names and string value according to the json specification
        for (char c : jsonString.toCharArray()) {
            if (c == '\'' || c == '\"') {
                quote = c;
                break;
            }
        }
        return quote;
    }
1067320
@Override
    public void toJSONString(JSONStringer stringer) throws JSONException {
        super.toJSONString(stringer);
        stringer.key("AGGREGATE_COLUMNS")
                .array();
        for (int ii = 0; ii < m_aggregateTypes.size(); ii++) {
            stringer.object();
            stringer.keySymbolValuePair(Members.AGGREGATE_TYPE.name(), m_aggregateTypes.get(ii).name());
            stringer.keySymbolValuePair(Members.AGGREGATE_OUTPUT_COLUMN.name(), m_aggregateOutputColumns.get(ii));
            AbstractExpression.toJSONArray(stringer,
                                           Members.AGGREGATE_EXPRESSIONS.name(),
                                           m_aggregateExpressions.get(ii));
            stringer.endObject();
        }
        stringer.endArray();
        AbstractExpression.toJSONArray(stringer,
                                       Members.PARTITIONBY_EXPRESSIONS.name(),
                                       m_partitionByExpressions);
        AbstractExpression.toJSONArrayFromSortList(stringer,
                                                   m_orderByExpressions,
                                                       null);
    }
1019713
public static HttpResponse postJson(String urlStr, String body)
            throws IOException {

        URL url = new URL(urlStr);
        HttpURLConnection urlConnection = (HttpURLConnection) url
                .openConnection();
        urlConnection.addRequestProperty("Accept", "application/json");

        urlConnection.setRequestMethod("POST");

        urlConnection.addRequestProperty("Content-Type", "application/json");
        urlConnection.addRequestProperty("Content-Length",
                Integer.toString(body.length()));
        urlConnection.setDoOutput(true);
        urlConnection.setDoInput(true);
        urlConnection.setUseCaches(false);

        OutputStream out = urlConnection.getOutputStream();
        out.write(body.getBytes());
        ByteStreams.copy(new ByteArrayInputStream(body.getBytes()),
                out);
        BufferedReader in = null;
        try {
            int errorCode = urlConnection.getResponseCode();
            if ((errorCode <= 202) && (errorCode >= 200)) {
                in = new BufferedReader(new InputStreamReader(
                        urlConnection.getInputStream()));
            } else {
                InputStream error = urlConnection.getErrorStream();
                if (error != null) {
                    in = new BufferedReader(new InputStreamReader(error));
                }
            }

            String json = null;
            if (in != null) {
                json = CharStreams.toString(in);
            }
            return new HttpResponse(errorCode, json);
        } finally {
            if(in != null){
                in.close();
            }
        }
    }
364018
private void initializeParser(JsonParser parser) throws IOException {
    if (wrapperKeys.isEmpty()) {
      return;
    }
    boolean failed = true;
    try {
      String match = parser.skipToKey(wrapperKeys);
      Preconditions.checkArgument(
          match != null && parser.getCurrentToken() != JsonToken.END_OBJECT,
          "wrapper key(s) not found: %s",
          wrapperKeys);
      failed = false;
    } finally {
      if (failed) {
        parser.close();
      }
    }
  }
119513
@SuppressWarnings("unchecked")
    public static CounterMetadata fromJsonString(String jsonString) {
        try {
            return fromMap(SerializationUtils.fromJsonString(jsonString, Map.class));
        } catch (Exception e) {
            return null;
        }
    }
1161661
public static CredentialOptions jsonCredentials(String jsonString) {
    return jsonCredentials(new ByteArrayInputStream(jsonString.getBytes(StandardCharsets.UTF_8)));
  }
95368
public static ResponseDeserializer getResponseDeserializer(String jsonStr) throws JsonParseException, JsonMappingException, IOException{
        final ResponsePair p = mapper.readValue(jsonStr, ResponsePair.class);
        Response rr = null;
        if(p.getType() != null){
            rr = (Response) mapper.readValue(p.getResponse(), p.getType());
        }
        final Response resp = rr;

        return new ResponseDeserializer(){

            @Override
            public ResponseHeader deserializerResponseHeader() {
                return p.getResponseHeader();
            }

            @Override
            public Response deserializerResponse() {
                return resp;
            }

        };

    }
27538
@SuppressWarnings("unchecked")
  public JsonNode createJsonNode(Object parameter) {
    if(parameter instanceof SpinJsonNode) {
      return (JsonNode) ((SpinJsonNode) parameter).unwrap();

    } else if(parameter instanceof String) {
      return createJsonNode((String) parameter);

    } else if(parameter instanceof Integer) {
      return createJsonNode((Integer) parameter);

    } else if(parameter instanceof Boolean) {
      return createJsonNode((Boolean) parameter);

    } else if(parameter instanceof Float) {
      return createJsonNode((Float) parameter);

    } else if(parameter instanceof Long) {
      return createJsonNode((Long) parameter);

    } else if(parameter instanceof Number) {
      return createJsonNode(((Number) parameter).floatValue());

    } else if(parameter instanceof List) {
      return createJsonNode((List<Object>) parameter);

    } else if(parameter instanceof Map) {
      return createJsonNode((Map<String, Object>) parameter);

    } else if (parameter == null) {
      return createNullJsonNode();
    } else {
      throw LOG.unableToCreateNode(parameter.getClass().getSimpleName());
    }
  }