Google Gson is an open source java based library developed by Google.
It facilitates serialization of Java objects to JSON and vice versa.
It facilitates serialization of Java objects to JSON and vice versa.
import com.google.gson.Gson;import java.util.HashMap;import java.util.Map;public class FormToGson {public FormToGson () {super();}public static void main(String[] args) {
Map map = new HashMap();map.put("Name", "Mahmoud");map.put("Job", "DEV");Gson gosn = new Gson();String paramsJsonString = gosn.toJson(map);System.out.println(paramsJsonString);HashMap map2 = gosn.fromJson(paramsJsonString, HashMap.class);System.out.println(map2.get("Name"));}}
/Servlet?params=paramsJsonString .
To downlaod the jar:
https://mvnrepository.com/artifact/com.google.code.gson/gson
No comments:
Post a Comment