Serialization and deserialization of JSON
Java serialization and deserialization is the conversion between a Java object and a stream of bytes, and the Java objects we create in the program exist only in the JVM, and when the program exits, the objects disappear, and the deserialization
Objects to be used by other JVMs, these serialized byte streams are not related to the JVM, which means that one JVM-serialized object can be deserialized in another JVM
Serialization must implement Serializable
Properties that cannot be serialized must be decorated with transient
Uploading from a background map to the foreground requires serialization-"
Response.setcontenttype ("Application/json"); Response.setheader ("Cache-control", "No-store"); MapNew hashmap<string, object>(); Map.put ("1", sbname); Response.getwriter (). Write (Jsonobject.fromobject (map). ToString ()); // someone is so serialized-"JSON." Encode (result);
The front-end receive needs to be deserialized
(1)functionGetsbname () {varSbcode = $ (' #sbcode '). Val (); varPars = ' sbcode= ' +Sbcode; $.ajax ({URL:' <%=path%>/tbsbdyyqcontroller.do?getsbname ', type:' Post ', Data:pars, DataType:' JSON ', Success:function(data) {varobj = eval (data);//to deserialize //find someone so deserializing var obj = decode (data);alert (obj.sbanem);//take a key value}} )} (2)functionGetsbname () {varSbcode = $ (' #sbcode '). Val (); varPars = ' sbcode= ' +Sbcode; $.ajax ({URL:' <%=path%>/tbsbdyyqcontroller.do?getsbname ', type:' Post ', Data:pars, DataType:' JSON ', Success:function(data) {$.each (data),function(index,value) {alert (value); }) $(' #sbtitle '). Val (data[1]); }})} (3)functionGetsbname () {varSbcode = $ (' #sbcode '). Val (); varPars = ' sbcode= ' +Sbcode; $.ajax ({URL:' <%=path%>/tbsbdyyqcontroller.do?getsbname ', type:' Post ', Data:pars, DataType:' JSON ', Success:function(data) {$ (' #sbtitle '). Val (data[1]); } }) }
HTML and JSON format for AJXA