sangmingming / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

how to generate a Primitive json from a String? #149

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I use 1.3 version, I don't know whether my problem, how will a json 
request directly format string directly into the client executable json 
request directly? For example:
Map<String,Object> map = new HashMap<String,Object>();
map.put("abc","abc");
map.put("data","[['1','a'],['2','b']]");

I hope generates code: {" ABC ":" ABC ", "data" : [[' 1 ', 'a'], [' 
2 ', 'b']], 
but not,I get:
{"abc":"abc","data":"[['1','a'],['2','b']]"}. Normally, we do not know 
what type of data format, here is String[][], to change how I get the 
result?

Original issue reported on code.google.com by wu.ar...@gmail.com on 21 Aug 2009 at 1:43

GoogleCodeExporter commented 9 years ago
Sorry but I do not understand this bug. Are you saying that you would like the 
type
information carried over to the client? That is not possible through any 
in-build
Json schemes. However, you can attach extra string properties for the values 
that
contain a hint for the type. 

Original comment by inder123 on 24 Aug 2009 at 5:26

GoogleCodeExporter commented 9 years ago
Please provide further information if you want us to keep this bug open. In any 
case, I am deferring it to a future 
release.

Original comment by inder123 on 29 Sep 2009 at 5:57

GoogleCodeExporter commented 9 years ago
This is clearly not a bug, the reporter is expecting some very bizarre 
behaviour.

I suppose, if he put something like:

map.put("data", new String[][] { {"1","a"},{"2","b"} });

and that will serialize to this: {"abc":"abc","data":[["1","a"],["2","b"]]}

Which is good.

Original comment by apri...@gmail.com on 22 Mar 2010 at 10:51

GoogleCodeExporter commented 9 years ago

Original comment by limpbizkit on 28 Aug 2010 at 5:43