Import Java.util.hashmap;import java.util.iterator;import Java.util.list;import Java.util.map;import Java.util.vector;import Com.alibaba.fastjson.jsonarray;import Com.alibaba.fastjson.jsonobject;import Com.led.image.transformutils;import com.ledsystem.util.encodingdetect;/** * @deprecated 锛 氳 canвt 鏋 manic son indent dress depleting * @author Gary Huang * @since: 1.0.0 * */@SuppressWarnings ("Unchecked") public class Jsonarrayutils {private list<nodeobject> nod ES = null;p ublic jsonarrayutils (String json) {try {Jsonarray Jsonarray = Jsonarray.parsearray (JSON); nodes = Parsenodes (js Onarray);} catch (Exception e) {e.printstacktrace ();}} List<nodeobject> parsenodes (jsonarray array) {list<nodeobject> nodes = new vector<nodeobject> (); int Size = Array.size (); for (int i = 0; i < size; i++) {try {jsonobject json = array.getjsonobject (i); Nodes.Add (Parsenodeo Bject (JSON));} catch (Exception e) {e.printstacktrace ();}} return nodes; }nodeobject Parsenodeobject (Jsonobject json) {nodeobject node = newNodeobject ();iterator<string> key = Json.keyset (). Iterator (); while (Key.hasnext ()) {String keyName = transformutils.tostring (Key.next ()); try {Object value = Json.get (keyName); if (Nu LL = = value) {continue;} if (value instanceof jsonobject) {node.put (KeyName, Parsenodeobject ((jsonobject) value)); }else if (value instanceof Jsonarray) {node.put (KeyName, Parsenodes ((Jsonarray) value)); }else{node.put (keyName, value);}} catch (Exception e) {e.printstacktrace ();}} return node;} Public list<nodeobject> Getnodes () {return nodes;} Public Nodeobject GetNode () {return nodes.get (0);} public static class Nodeobject{private map<string, object> datas = new hashmap<string, object> ();p ublic void P UT (String key, Object value) {datas.put (key, value);} Public Object get (String key) {return datas.get (key); } @Overridepublic String toString () {return datas.tostring ();}} public static class Nodeitem{private string key;p rivate Object value;p ublic string GetKey () {return Key;} public void Setkey (String key) {This.key = key;} Public Object GetValue () {return value;} public void SetValue (Object value) {this.value = value,} public nodeobject GetNode () {return (Nodeobject) This.value;} Public list<nodeobject> Getnodes () {return ((list<nodeobject>) this.value); @Overridepublic String toString () {return "key:" + key + "value:" + Value;}}
The Java wrapper parses the JSON data.