Package org.openx.data.jsonserde.json

Examples of org.openx.data.jsonserde.json.JSONArray


        assertTrue(19.5 == jsfOi.get(soi.getStructFieldData(result, soi.getStructFieldRef("two"))));
       
        Object ar = soi.getStructFieldData(result, soi.getStructFieldRef("three"));
        assertTrue(ar instanceof JSONArray);
       
        JSONArray jar = (JSONArray)ar;
        assertTrue( jar.get(0) instanceof String );
        assertEquals("red", jar.get(0));
       
    }
View Full Code Here


            String txt = rowText.toString().trim();
           
            if(txt.startsWith("{")) {
                jObj = new JSONObject(txt);
            } else if (txt.startsWith("[")){
                jObj = new JSONArray(txt);
            }
        } catch (JSONException e) {
            // If row is not a JSON object, make the whole row NULL
            onMalformedJson("Row is not a valid JSON Object - JSONException: "
                    + e.getMessage());
View Full Code Here

        // could be an array of whatever!
        // we do it in reverse order since the JSONArray is grown on demand,
        // as higher indexes are added.
        if(obj==null) { return null; }
       
        JSONArray ar = new JSONArray();
        for(int i=loi.getListLength(obj)-1; i>=0; i--) {
            Object element = loi.getListElement(obj, i);
            try {
                ar.put(i, serializeField(element, loi.getListElementObjectInspector() ) );
            } catch (JSONException ex) {
                LOG.warn("Problem serializing array", ex);
                throw new RuntimeException(ex);
            }
        }
View Full Code Here

     @Override
  public List<?> getList(Object data) {
    if (data == null || JSONObject.NULL.equals(data)) {
      return null;
    }
    JSONArray array = (JSONArray) data;
    List al = new ArrayList(array.length());
    for(int i =0; i< array.length(); i++) {
  al.add(getListElement(data,i));
    }
    return al;
  }
View Full Code Here

  @Override
  public Object getListElement(Object data, int index) {
    if (data == null) {
      return null;
    }
    JSONArray array = (JSONArray) data;
    try {
        Object obj =  array.get(index);
  if(JSONObject.NULL == obj) {
      return null;
  } else {
      return obj;
  }
View Full Code Here

  @Override
  public int getListLength(Object data) {
    if (data == null) {
      return -1;
    }
    JSONArray array = (JSONArray) data;
    return array.length();
  }
View Full Code Here

TOP

Related Classes of org.openx.data.jsonserde.json.JSONArray

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.