Package org.jtester.json.helper

Examples of org.jtester.json.helper.JSONObject


   */
  public static final <T> T toObject(String json) {
    if (json == null) {
      return null;
    }
    JSONObject jsonObject = JSONScanner.scnJSON(json);

    Object o = toObject(jsonObject, new HashMap<String, Object>());
    return (T) o;
  }
View Full Code Here


  public static final <T> T toObject(String json, Class clazz) {
    if (json == null) {
      return null;
    }
    JSONObject jsonObject = JSONScanner.scnJSON(json);

    Object o = toObject(jsonObject, clazz, new HashMap<String, Object>());
    return (T) o;
  }
View Full Code Here

  }

  private T decodeFromJSONMap(JSONMap map, Map<String, Object> references) {
    Class clazz = map.getClazzFromJSONFProp(this.clazz);

    JSONObject json = map.getValueFromJSONProp();
    if (!(json instanceof JSONSingle)) {
      throw new RuntimeException(
          "illegal syntax, the JSONObject value of Single Type Object can only be JSONSingle.");
    }
    String value = ((JSONSingle) json).toStringValue();
View Full Code Here

    T object = this.decodeFromString(value);
    return object;
  }

  protected T decodeFromJSONMap(JSONMap map) {
    JSONObject jsonObject = map.getValueFromJSONProp();
    if (jsonObject instanceof JSONSingle) {
      T o = this.decodeFromJSONSingle((JSONSingle) jsonObject);
      return o;
    } else {
      throw new RuntimeException("illegal syntax.");
View Full Code Here

  }

  @Override
  protected void parseFromJSONMap(Map target, JSONMap jsonMap, Map<String, Object> references) {
    for (Iterator<JSONObject> iterator = jsonMap.keySet().iterator(); iterator.hasNext();) {
      JSONObject jsonkey = iterator.next();

      if (jsonkey.equals(JSONMap.JSON_ClazzFlag)) {
        continue;
      }
      Object key = JSON.toObject(jsonkey, references);
      JSONObject jsonvalue = jsonMap.get(jsonkey);
      Object value = JSON.toObject(jsonvalue, references);
      target.put(key, value);
    }
  }
View Full Code Here

      this.realTargetType = type;
    } else {
      this.realTargetType = type.getComponentType();
    }

    JSONObject array = map.getValueFromJSONProp();
    if (!(array instanceof JSONArray)) {
      throw new JSONException("illegal type for ArrayDecoder. the type can only be JSONArray, but actual is "
          + array.getClass().getName());
    }
    T target = this.newArraysObject(((JSONArray) array).size());
    referenceID = map.getReferenceID();
    if (referenceID != null) {
      references.put(referenceID, target);
View Full Code Here

  }

  private final void parseFromJSONArray(T target, JSONArray jsonArray, Map<String, Object> references) {
    int index = 0;
    for (Iterator<JSONObject> it = jsonArray.iterator(); it.hasNext();) {
      JSONObject jsonObject = it.next();
      this.setObjectByIndex(target, index, jsonObject, references);
      index++;
    }
  }
View Full Code Here

@SuppressWarnings({ "rawtypes", "unchecked" })
public class JSONAssert extends AllAssert<Object, JSONAssert> implements IJSONAssert {

  public JSONAssert(String json, Class<? extends IAssert<?, ?>> clazE) {
    super(clazE);
    JSONObject temp = JSONScanner.scnJSON(json);
    this.value = convert(temp);
    this.type = AssertType.AssertStyle;
  }
View Full Code Here

TOP

Related Classes of org.jtester.json.helper.JSONObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.