Package org.structr.core

Examples of org.structr.core.JsonInput


  @Override
  public IJsonInput deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {

    IJsonInput jsonInput = null;
    JsonInput wrapper = null;
    if (json.isJsonObject()) {
      jsonInput = new JsonSingleInput();
      wrapper = deserialize(json, context);
      jsonInput.add(wrapper);
View Full Code Here


  }
 
 
  private JsonInput deserialize(JsonElement json, JsonDeserializationContext context) throws JsonParseException {

    JsonInput wrapper = new JsonInput();
    if (json.isJsonObject()) {
      JsonObject obj = json.getAsJsonObject();

      for (Entry<String, JsonElement> entry : obj.entrySet()) {

        String key       = entry.getKey();
        JsonElement elem = entry.getValue();

        // static mapping of IdProperty if present
        if ((idProperty != null) && "id".equals(key)) {

          key = idProperty.jsonName();

        }

        if (elem.isJsonNull()) {

          wrapper.add(key, null);

        } else if (elem.isJsonObject()) {

          wrapper.add(key, deserialize(elem, context));

        } else if (elem.isJsonArray()) {

          JsonArray array = elem.getAsJsonArray();
          List list = new LinkedList();
          for(JsonElement element : array) {
            if (element.isJsonPrimitive()) {
              list.add(fromPrimitive((element.getAsJsonPrimitive())));
            } else if(element.isJsonObject()) {
              // create map of values
              list.add(deserialize(element, context));
            }
          }

          wrapper.add(key, list);

        } else if (elem.isJsonPrimitive()) {

          // wrapper.add(key, elem.getAsString());
          wrapper.add(key, fromPrimitive(elem.getAsJsonPrimitive()));
        }

      }

    } else if(json.isJsonArray()) {

      JsonArray array = json.getAsJsonArray();
      for(JsonElement elem : array) {
        wrapper = new JsonInput();
        if (elem.isJsonPrimitive()) {
          wrapper.add(elem.toString(), fromPrimitive(elem.getAsJsonPrimitive()));
        } else if(elem.isJsonObject()) {
          wrapper.add(elem.toString(), deserialize(elem, context));
        } else if(elem.isJsonArray()) {
          wrapper.add(elem.toString(), deserialize(elem, context));
        }
      }
    }

    return wrapper;
View Full Code Here

      Result<T> results = Result.EMPTY_RESULT;
     
      if (source instanceof JsonInput) {

        JsonInput properties = (JsonInput) source;
        PropertyMap map      = PropertyMap.inputTypeToJavaType(securityContext, type, properties.getAttributes());
       
        // If property map contains the uuid, search only for uuid
        if (map.containsKey(GraphObject.id)) {
       
          return (T) app.get(map.get(GraphObject.id));
View Full Code Here

TOP

Related Classes of org.structr.core.JsonInput

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.