首先得有gson包,,请自行百度下一个,然后附加到项目,这个就不说了,
然后序列化成json字符串,
String objStr= new GsonBuilder().serializeNulls().create() .toJson( object );
HashMap<String, Object> data = new Gson()
.fromJson(objStr, new TypeToken<HashMap<String, Object>>()
{
}.getType());
for (Object o : data.keySet())
{
System.out.println(o+"");
}
</pre><pre name="code" class="java">
</pre><pre name="code" class="java">