Read json from stream.

@param json the json
@return the string
@throws IOException the io exception
496961
protected String readJsonFrom(final InputStream json) throws IOException {
        return isJsonFormat()
            ? JsonValue.readHjson(IOUtils.toString(json, StandardCharsets.UTF_8)).toString()
            : String.join("\n", IOUtils.readLines(json, StandardCharsets.UTF_8));
    }
167374
public JSON readFromStream( InputStream stream ) {
      try{
         StringBuffer xml = new StringBuffer();
         BufferedReader in = new BufferedReader( new InputStreamReader( stream ) );
         String line = null;
         while( (line = in.readLine()) != null ){
            xml.append( line );
         }
         return read( xml.toString() );
      }catch( IOException ioe ){
         throw new JSONException( ioe );
      }
   }
1222177
public String toJson() throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        mapper.writeValue(out, this);
        return out.toString();
    }
1003468
@SuppressWarnings({"unchecked"})
    public <T> T read(InputStream jsonInputStream) throws IOException {
        return read(jsonInputStream, Configuration.defaultConfiguration());
    }
734848
public static Map toMap(String json) {
        try {
            return mapper.readValue(json, Map.class);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
255572
public void toJson(JsonElement jsonElement, JsonWriter writer) throws JsonIOException {
    boolean oldLenient = writer.isLenient();
    writer.setLenient(true);
    boolean oldHtmlSafe = writer.isHtmlSafe();
    writer.setHtmlSafe(htmlSafe);
    boolean oldSerializeNulls = writer.getSerializeNulls();
    writer.setSerializeNulls(serializeNulls);
    try {
      Streams.write(jsonElement, writer);
    } catch (IOException e) {
      throw new JsonIOException(e);
    } catch (AssertionError e) {
      AssertionError error = new AssertionError("AssertionError (GSON " + GsonBuildConfig.VERSION + "): " + e.getMessage());
      error.initCause(e);
      throw error;
    } finally {
      writer.setLenient(oldLenient);
      writer.setHtmlSafe(oldHtmlSafe);
      writer.setSerializeNulls(oldSerializeNulls);
    }
  }
250041
public T parse(InputStream is) throws IOException {
        JsonParser jsonParser = LoganSquare.JSON_FACTORY.createParser(is);
        jsonParser.nextToken();
        return parse(jsonParser);
    }
433432
def read_json(self):
        
        line = self.stdin.readline()
        if line == '':
            raise EOFError()
        return json.loads(line)
926032
@Override
    protected Asset readJson(final String assetId) throws IOException, BadVersionException {
        FileInputStream fis = null;
        try {
            fis = DirectoryUtils.createFileInputStream(createFromRelative(assetId + ".json"));
            Asset ass = processJSON(fis);
            return ass;
        } finally {
            if (fis != null) {
                fis.close();
            }
        }
    }
807260
public T get(String json) throws IOException, JsonFormatException {
		JsonPullParser parser = JsonPullParser.newParser(json);
		return get(parser, null);
	}
574717
public ReadJSON reader() {
        Object obj = checkNotNull(this.delegate.orNull(), "The delegate object cannot be null");
        checkArgument(obj instanceof String, "The delegate object must be JSON string");
        return new ReadJSON((String) obj, this);
    }
117347
public static WorkflowRuleTarget fromJson(String json) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.readValue(json, WorkflowRuleTarget.class);
    }
35141
public void loadFromJSON(final InputStream is) throws IOException {
		lock.writeLock().lock();
		try {
			final JsonFactory f = new JsonFactory();
			final JsonParser jp = f.createParser(is);
			configureJsonParser(jp);
			if (jp.nextToken() == JsonToken.START_OBJECT) {
				traverseJSON(jp, null);
			}
		} finally {
			lock.writeLock().unlock();
		}
	}
1030935
public void showJson(String json) {
		try {
			JsonFactory jsonFactory = new JsonFactory();
			ObjectMapper objectMapper = new ObjectMapper();
			StringWriter stringWriter = new StringWriter();

			JsonParser jsonParser = jsonFactory.createJsonParser(new StringReader(json));
			JsonNode jsonNode = objectMapper.readTree(jsonParser);
			JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(stringWriter);
			jsonGenerator.useDefaultPrettyPrinter();

			objectMapper.writeTree(jsonGenerator, jsonNode);

			jsonGenerator.flush();
			jsonGenerator.close();
		} catch (Throwable throwable) {
			// hmm, somewhat accidentally crashed?
		}
	}
536566
public static WorkflowRule fromJson(String json) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.readValue(json, WorkflowRule.class);
    }
682603
public static Workspace fromJson(String json) throws Exception {
        if (json == null || json.trim().length() == 0) {
            throw new IllegalArgumentException("A JSON string must be provided.");
        }

        StringReader stringReader = new StringReader(json);
        return new JsonReader().read(stringReader);
    }
48383
private JsonArray getJsonFromResponse(HttpResponse response) throws IOException
    {
        InputStream content = response.getEntity().getContent();
        Reader reader = new InputStreamReader(content);
        JsonObject json = gson.fromJson(reader, JsonObject.class);
        JsonElement jsonElement = json.get("rows");
        return jsonElement == null ? null : jsonElement.getAsJsonArray();
    }