Back to project page json2view.
The source code is released under:
MIT License
If you think the Android project json2view listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.avocarrot.json2view; /* w w w . j a v a 2 s . c o m*/ import org.json.JSONArray; import org.json.JSONObject; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class DynamicViewJsonBuilder { private String widget = ""; private List<JSONObject> properties; private List<JSONObject> views; public DynamicViewJsonBuilder() { properties = new ArrayList<>(); views = new ArrayList<>(); } public DynamicViewJsonBuilder setWidget(String widget) { this.widget = widget; return this; } public DynamicViewJsonBuilder addProperty(JSONObject property) { this.properties.add(property); return this; } public DynamicViewJsonBuilder addView(JSONObject view) { this.views.add(view); return this; } public JSONObject build() { Map<String, Object> map = new HashMap<>(); map.put("widget", widget); map.put("properties", new JSONArray(properties)); map.put("views", new JSONArray(views)); return new JSONObject(map); } }