本文整理汇总了Java中org.json.simple.parser.ContainerFactory类的典型用法代码示例。如果您正苦于以下问题:Java ContainerFactory类的具体用法?Java ContainerFactory怎么用?Java ContainerFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContainerFactory类属于org.json.simple.parser包,在下文中一共展示了ContainerFactory类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createContainerFactory
import org.json.simple.parser.ContainerFactory; //导入依赖的package包/类
private ContainerFactory createContainerFactory() {
return new ContainerFactory() {
@Override
public Map createObjectContainer() {
return new LinkedHashMap();
}
@Override
public List creatArrayContainer() {
return new LinkedList();
}
};
}
示例2: createJsonParser
import org.json.simple.parser.ContainerFactory; //导入依赖的package包/类
private void createJsonParser()
{
this.parser = new JSONParser();
containerFactory = new ContainerFactory()
{
@Override
public List creatArrayContainer()
{
return new LinkedList();
}
@Override
public Map createObjectContainer()
{
return new LinkedHashMap();
}
};
}
示例3: initialize
import org.json.simple.parser.ContainerFactory; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private void initialize() {
try {
JSONParser parser = new JSONParser();
ContainerFactory containerFactory = new ContainerFactory() {
public List creatArrayContainer() {
return new LinkedList();
}
public Map createObjectContainer() {
return new LinkedHashMap();
}
};
if (!StringUtils.isEmpty(this.response)) {
Object parse = parser.parse(this.response, containerFactory);
if (parse instanceof List) {
this.jsonMap = new LinkedHashMap();
} else {
this.jsonMap = (Map) parse;
}
this.jsonMap.put("root", parse);
} else {
this.jsonMap = new HashMap();
}
} catch (Exception ex) {
logger.warn("Unable to parse the response string as a JSON object: " + this.response, ex);
}
}
示例4: createObjectContainer
import org.json.simple.parser.ContainerFactory; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private Map createObjectContainer(ContainerFactory containerFactory) {
if (containerFactory == null)
return new JSONObject();
Map m = containerFactory.createObjectContainer();
if (m == null)
return new JSONObject();
return m;
}
示例5: createArrayContainer
import org.json.simple.parser.ContainerFactory; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private List createArrayContainer(ContainerFactory containerFactory) {
if (containerFactory == null)
return new JSONArray();
List l = containerFactory.creatArrayContainer();
if (l == null)
return new JSONArray();
return l;
}