public JSONValue toJSON(Object aPojo) throws MapperException { JSONArray lArray = new JSONArray(); if(! Collection.class.isAssignableFrom(aPojo.getClass())) throw new MapperException("CollectionMapper cannot map: " + aPojo.getClass().getName()); Collection lColl = (Collection) aPojo; for(Object lEl : lColl) { lArray.getValue().add(JSONMapper.toJSON(lEl)); } return lArray; } }
public void renderValue(Object aObj, JSONObject aObjectElement, JSONMarshall aMarshall, HashMap aPool) throws MarshallException { // We create a new JSON array where we will collect the elements of the // collection. We attach this new array as the parent object value. final JSONArray lArray = new JSONArray(); aObjectElement.getValue().put(JSONMarshall.RNDR_ATTR_VALUE, lArray); // We iterate through the elements of the collection, render these as // JSON values and put these values in the array created above. final Collection lCollection = (Collection) aObj; for(Object lColEl : lCollection) { lArray.getValue().add(aMarshall.marshallImpl(lColEl, aPool)); } }
public void renderValue(Object aObj, JSONObject aObjectElement, JSONMarshall aMarshall, HashMap aPool) throws MarshallException { // We create a new JSON array where we will collect the elements of the // map. We attach this new array as the parent object value. final JSONArray lArray = new JSONArray(); aObjectElement.getValue().put(JSONMarshall.RNDR_ATTR_VALUE, lArray); // We iterate through the keys of the map, render these as // JSON values and put these values in the array created above. final Map lMap = (Map) aObj; final Iterator lIter = lMap.keySet().iterator(); for(Object lKey : lMap.keySet()) { // Get hold of each key-value pair. final Object lValue = lMap.get(lKey); // We create a JSON object to render the key-value pairs. final JSONObject lKeyValuePair = new JSONObject(); lArray.getValue().add(lKeyValuePair); lKeyValuePair.getValue().put(ATTR_KEY, aMarshall.marshallImpl(lKey, aPool)); lKeyValuePair.getValue().put(ATTR_VALUE, aMarshall.marshallImpl(lValue, aPool)); } }
final JSONArray lElements = new JSONArray();
final JSONArray lArray = new JSONArray(); for(Object lElement : ((List) anObject))
final String lComponentName = lComponentAttr.getValue(); final JSONArray lElements = new JSONArray(); aObjectElement.getValue().put(JSONMarshall.RNDR_ATTR_VALUE, lElements);
public final JSONArray array( String aStreamName ) throws RecognitionException, TokenStreamException { JSONArray lResult=new JSONArray();