[google-gson:625]: convert bitset to json

361 views
Skip to first unread message

chuang

unread,
Apr 22, 2010, 2:57:44 AM4/22/10
to google-gson
Hi:

I had a problem converting a java BitSet to and from json. Here is my
code. Value of the bitset is not the same after I convert it to json
string, and then back to Object. Please help.

Chuang

Gson gson_ = new Gson();

BitSet set = new BitSet(10);
set.set(1);
set.set(5);

System.out.println(set.get(1));
System.out.println(set.get(5));

String output = gson_.toJson(set);
BitSet set2 = gson_.fromJson(output, BitSet.class);

System.out.println(set2.get(1));
System.out.println(set2.get(5));

--
You received this message because you are subscribed to the Google Groups "google-gson" group.
To post to this group, send email to googl...@googlegroups.com.
To unsubscribe from this group, send email to google-gson...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-gson?hl=en.

inde...@gmail.com

unread,
Apr 27, 2010, 12:20:36 PM4/27/10
to google-gson
Seems like a bug in Gson. I have filed a bug:
http://code.google.com/p/google-gson/issues/detail?id=207
We will try to fix it in the next release of Gson.

Thanks for the detailed example to reproduce the bug
Inder
Reply all
Reply to author
Forward
0 new messages