Package com.sdicons.json.model

Examples of com.sdicons.json.model.JSONObject


     * @see de.netseeker.ejoe.adapter.SerializeAdapter#read(java.io.InputStream)
     */
    public Object read( InputStream in ) throws Exception
    {
        JSONParser parser = new JSONParser( in );
        JSONObject jObj = (JSONObject) parser.nextValue();
        Marshall marshaller = new JSONMarshall();
        return marshaller.unmarshall( jObj ).getReference();
    }
View Full Code Here


     * @see de.netseeker.ejoe.adapter.SerializeAdapter#write(java.lang.Object, java.io.OutputStream)
     */
    public void write( Object obj, OutputStream out ) throws Exception
    {
        Marshall marshaller = new JSONMarshall();
        JSONObject jObj = marshaller.marshall( obj );
        super.write( jObj.render( false ), out );
    }
View Full Code Here

      int cont = 0;
      JSONParser parser = new JSONParser(response);
      JSONValue jsonObject = parser.nextValue();
      if (jsonObject.isComplex()) {

        JSONObject complex = (JSONObject) jsonObject;
        JSONObject jsonResults = (JSONObject) complex.get("results");
        JSONArray bindings = (JSONArray) jsonResults.get("bindings");
        for (int i = 0; i < bindings.getValue().size(); i++) {
          Map<String, String> result = new HashMap<String, String>();
          cont++;
          JSONObject jsonResult = (JSONObject) bindings.get(i);
          for (String var : getVariablesFromJson(complex)) {
            JSONObject element = (JSONObject) jsonResult.get(var);
            String value = null;
            if (element != null) {
              String type = ((JSONString) element.get("type"))
                  .getValue();
              value = ((JSONString) element.get("value"))
                  .getValue();
              value = ((JSONString) element.get("value"))
                  .getValue();
              if (!type.equals("uri")) {
                if (((JSONString) element.get("datatype")) != null) {
                  String datatype = ((JSONString) element
                      .get("datatype")).getValue();
                  if (datatype != null
                      && !"".equals(datatype))
                    value += "^^" + datatype;
                }
View Full Code Here

  }

  private LinkedList<String> getVariablesFromJson(JSONObject complex) {
    LinkedList<String> variables = new LinkedList<String>();
    JSONObject jsonHead = (JSONObject) complex.get("head");
    JSONArray vars = (JSONArray) jsonHead.get("vars");
    for (int i = 0; i < vars.getValue().size(); i++) {
      variables.add(((JSONString) vars.get(i)).getValue());
    }
    return variables;
  }
View Full Code Here

    }

    @Override
    public Object toJava(JSONValue aValue, Class aRequestedClass) throws MapperException {
  if (aValue.isObject()) {
      final JSONObject jsonObject = (JSONObject) aValue;
      final AjUser out = new AjUser();
      out.setIdUser(Helper.getIntRequired(jsonObject, "idUser",
        "AjUser property idUser was not found in json data"));
      out.setIdImageIcon(Helper.getIntRequired(jsonObject, "idImageIcon",
        "AjUser property IdImageIcon was not found in json data"));
View Full Code Here

    @Override
    public JSONValue toJSON(Object aPojo) throws MapperException {
  if (aPojo instanceof AjUser) {
      AjUser user = (AjUser) aPojo;
      final JSONObject lElements = new JSONObject();
      lElements.getValue().put("idUser", JSONMapper.toJSON(user.getIdUser()));
      lElements.getValue().put("idImageIcon", JSONMapper.toJSON(user.getIdImageIcon()));
      lElements.getValue().put("birthDate", JSONMapper.toJSON(user.getBirthDate()));
      lElements.getValue().put("userName", JSONMapper.toJSON(user.getUserName()));
      lElements.getValue().put("email", JSONMapper.toJSON(user.getEmail()));
      lElements.getValue().put("idBlog", JSONMapper.toJSON(user.getIdBlog()));
      lElements.getValue().put("lastLogin", JSONMapper.toJSON(user.getLastLogin()));
      lElements.getValue().put("registrationDate",
        JSONMapper.toJSON(user.getRegistrationDate()));
      return lElements;
  } else {
      throw new MapperException();
  }
View Full Code Here

    }

    @Override
    public Object toJava(JSONValue aValue, Class aRequestedClass) throws MapperException {
  if (aValue.isObject()) {
      final JSONObject jsonObject = (JSONObject) aValue;
      final AjSelectionRange out = new AjSelectionRange();
      final JSONValue fromJsonValue = jsonObject.get("from");
      if (fromJsonValue == null) {
    out.setFrom(-1);
      } else {
    out.setFrom((Integer) JSONMapper.toJava(fromJsonValue, Integer.class));
      }
      final JSONValue toJsonValue = jsonObject.get("to");
      if (toJsonValue == null) {
    out.setTo(Integer.MAX_VALUE);
      } else {
    out.setTo((Integer) JSONMapper.toJava(jsonObject.get("to"), Integer.class));
      }
      return out;
  }
  throw new MapperException("BooleanMapper cannot map: " + aValue.getClass().getName());
    }
View Full Code Here

    }

    @Override
    public JSONValue toJSON(Object aPojo) throws MapperException {
  AjSelectionRange range = (AjSelectionRange) aPojo;
  final JSONObject out = new JSONObject();
  out.getValue().put("from", new JSONString(String.valueOf(range.getFrom())));
  out.getValue().put("to", new JSONString(String.valueOf(range.getTo())));
  return out;
    }
View Full Code Here

    }

    @Override
    public Object toJava(JSONValue aValue, Class aRequestedClass) throws MapperException {
  if (aValue.isObject()) {
      final JSONObject jsonObject = (JSONObject) aValue;
      final AjProperty out = new AjProperty();
      out.setIdProperty(Helper.getIntRequired(jsonObject, "idProperty",
        "AjProperty property idProperty was not found in json data"));
      out.setName(Helper.getStringRequired(jsonObject, "name",
        "AjProperty property name was not found in json data"));
      out.setValues(new ArrayList<AjPropertyValue>());
      JSONArray array = (JSONArray) jsonObject.get("values");
      for (JSONValue jsonValue : array.getValue()) {
    out.getValues().add(
      (AjPropertyValue) JSONMapper.toJava(jsonValue, AjPropertyValue.class));
      }
      return out;
View Full Code Here

    }

    @Override
    public Object toJava(JSONValue aValue, Class aRequestedClass) throws MapperException {
  if (aValue.isObject()) {
      final JSONObject jsonObject = (JSONObject) aValue;
      final AjPropertyValue out = new AjPropertyValue();

      out.setIdPropertyValue(Helper.getIntRequired(jsonObject, "idPropertyValue",
        "AjPropertyValue property idPropertyValue was not found in json data"));
      out.setName(Helper.getStringRequired(jsonObject, "name",
View Full Code Here

TOP

Related Classes of com.sdicons.json.model.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.