1 package com.freemindcafe.serialization.sample3;
3 import java.util.ArrayList;
4 import java.util.HashMap;
8 import junit.framework.Assert;
10 import org.junit.Test;
17 public void map_to_json(){
18 Map<String, String> workerUri =
new HashMap<>();
19 workerUri.put(
"hostname",
"localhost");
20 workerUri.put(
"port",
"9449");
21 workerUri.put(
"mbean",
"com.freemindcafe");
24 System.out.println(jsonUsingJackson);
27 System.out.println(jsonUsingJettison);
30 Assert.assertEquals(workerUri, deserializedWorkerUri);
34 public void list_to_json(){
35 Map<String, String> workerUri1 =
new HashMap<>();
36 workerUri1.put(
"hostname",
"localhost");
37 workerUri1.put(
"port",
"9449");
38 workerUri1.put(
"mbean",
"com.freemindcafe");
40 Map<String, String> workerUri2 =
new HashMap<>();
41 workerUri2.put(
"hostname",
"localhost");
42 workerUri2.put(
"port",
"9449");
43 workerUri2.put(
"mbean",
"com.freemindcafe");
45 List<Map<String,String>> uris =
new ArrayList<>();
51 System.out.println(jsonUsingJackson);
54 System.out.println(jsonUsingJettison);
static< T > String objectToJson(final Object t, final Class< T > clazz)
static< TextendsObject > T jsonToObject(final String json, final Class< T > clazz)
Xstream and Jettison based serialization Jackson is arguably the standard Java Library for processing...