001package org.nuxeo.box.api.marshalling.jsonentities; 002 003import org.nuxeo.box.api.marshalling.exceptions.BoxJSONException; 004import org.nuxeo.box.api.marshalling.interfaces.IBoxJSONParser; 005 006import java.util.ArrayList; 007import java.util.Map; 008 009/** 010 * A special MapJSONStringEntity, when serializing into JSON, it's serialized into array of pairs. 011 */ 012public class PairArrayJSONStringEntity extends MapJSONStringEntity { 013 014 private static final long serialVersionUID = 1L; 015 016 @Override 017 public String toJSONString(IBoxJSONParser parser) throws BoxJSONException { 018 ArrayList<MapJSONStringEntity> list = new ArrayList<MapJSONStringEntity>(); 019 for (Map.Entry<String, Object> entry : this.entrySet()) { 020 MapJSONStringEntity entity = new MapJSONStringEntity(); 021 entity.put(entry.getKey(), entry.getValue()); 022 list.add(entity); 023 } 024 return parser.convertBoxObjectToJSONStringQuietly(list); 025 } 026}