Method for reading a JSON Object from input and building a {@link java.util.Map}
out of it. Note that if input does NOT contain a
JSON Object, {@link JSONObjectException} will be thrown.
356576
public Map<Object,Object> readMap() throws IOException {
        if (_parser.isExpectedStartObjectToken()) {
            return AnyReader.std.readFromObject(this, _parser, _mapBuilder);
        }
        if (_parser.hasToken(JsonToken.VALUE_NULL)) {
            return null;
        }
        throw JSONObjectException.from(_parser,
                "Can not read a Map: expect to see START_OBJECT ('{'), instead got: "+ValueReader._tokenDesc(_parser));
    }
1244978
@Override
    public Object map(Object input) {
        String orig = input.toString();
        if (map.containsKey(orig)) {
            return map.get(orig);
        }

        if (input instanceof String)
            return input;
        else
            return orig;
    }
492998
public JSONObject instantiateJsonObject(InputStream in) throws IOException,
                                                                JSONException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    StringBuffer contents = new StringBuffer();
    String text = null;
    while ((text = reader.readLine()) != null) {
      contents.append(text).append(System.getProperty("line.separator"));
    }
    in.close();
    JSONObject json = new JSONObject(contents.toString());
    return json;
  }
947868
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
        jsonObject = Utils.mapper().readValue((DataInput) stream, ObjectNode.class);
    }
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();
        }
    }
346917
private void readObject(java.io.ObjectInputStream s)
        throws java.io.IOException, ClassNotFoundException {
        s.defaultReadObject();
        Object ex = s.readObject();
        if (ex != null)
            setExceptionalCompletion((Throwable)ex);
    }
579385
public static JSONObject getJSONObject(HttpPost request, Integer method, HashMap<String, String> params) throws JSONException {
        switch (method) {
        case METHOD_PUT:
        case METHOD_DELETE:
        case METHOD_POST:
            return doPostRequest(request, params);
        default:
            throw new RuntimeException("Wrong http method requested");
        }
    }
620841
protected Map jsonMap() {
        checkJsonContentType();
        try {
            return JsonHelper.toMap(getRequestString());
        } catch (IOException e) {
            throw new WebException(e);
        }
    }
534621
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {
		// Read in size, and any hidden stuff
		s.defaultReadObject();
		
		this.stringDecoder = new Utf8();
		this.in = null;
	}
548419
public JSONObject toJSON() throws JSONException {
        JSONObject json = new JSONObject();

        json.put(JSON_TYPE, this.getType());

        return json;
    }
646669
@Trivial
    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
        GetField fields = in.readFields();
        failure = (Throwable) fields.get(FAILURE, null);
        params = (String[]) fields.get(PARAMS, new String[] {});
        reason = fields.get(REASON, (short) 0);
    }
1271425
@Override
	public void read(final DataInput in) throws IOException {
		int size = in.readInt();
		this.map.clear();

		try {
			for (; size > 0; size--) {
				final K key = this.keyClass.newInstance();
				final V val = this.valueClass.newInstance();
				key.read(in);
				val.read(in);
				this.map.put(key, val);
			}
		} catch (final InstantiationException e) {
			throw new RuntimeException(e);
		} catch (final IllegalAccessException e) {
			throw new RuntimeException(e);
		}
	}
837360
@Override
    public Object readMap(AbstractHessianInput in)
        throws IOException
    {
        Object value = null;

        while (!in.isEnd()) {
            String key = in.readString();

            if (key.equals("value"))
                value = readStreamValue(in);
            else
                in.readObject();
        }

        in.readMapEnd();

        return value;
    }
522570
public static JSONObject mapToJsonObject(Map<String, Object> map)
    {
        JSONObject jsonObj = new JSONObject();
        
        try {
            for (String key : map.keySet())
            {
                Object value = map.get(key);
                if (value instanceof Map)
                    jsonObj.put(key, AjaxProxyTask.mapToJsonObject((Map)value));
                else
                    jsonObj.put(key, value);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        
        return jsonObj;
    }
781330
public static Map<String, Comparable> fromJsonObject(JsonObject object) {
        if (object == null || object.isNull() || object.isEmpty()) {
            return Collections.emptyMap();
        }
        Map<String, Comparable> map = MapUtil.createHashMap(object.size());
        for (String propertyName : object.names()) {
            map.put(propertyName, object.get(propertyName).asString());
        }
        return map;
    }
708766
public Map<?, ?> formatJSON2Map(String json) {
		Map<?, ?> map = null;
		try {
			map = MAPPER.readValue(json, Map.class);
		} catch (Exception e) {
			LOGGER.error("formatJsonToMap error, json = " + json, e);
		}
		return map;
	}
449006
public static Object fromJson(String json) {
    try {
      JSONObject jsonObject = new JSONObject(json);
      if (jsonObject.has("JSON")) {
        return convert(jsonObject.get("JSON"));
      } else {
        return convert(jsonObject);
      }
    } catch (Exception e) {
      throw new RuntimeException("json=" + json, e);
    }
  }