Fastjson: "{\"v\":[\" \",\"abc\",\"x\",\"abc\"]}" with generic Map<String,char[]> still through parse?

Created on 14 Aug 2016  ·  6Comments  ·  Source: alibaba/fastjson

String str1="{\"v\":[\" \",\"abc\",\"x\",\"abc\"]}";
Map<String, char[]> map = JSON.parseObject(str1,
new com.alibaba.fastjson.TypeReference<Map<String, char[]>>() {
});
System.out.println(new String(map.get("v")));

and then,it outpputs-> [" ","abc","x","abc"]
Is it right?
Actually If the generic is Map

bug

Most helpful comment

@wenshao

Your response doesn't make sense. You put in something that is the direct cause of the unexpected behavior of FastJson, which needs to be fixed:

array.toString().toCharArray();

The code above is crappy and doesn't capture the right intention.

While Jackson's behavior is much more appreciated:

image

This issue is NOT a question, it is a bug report about a misleading behavior of FastJson.

All 6 comments

Get this result because:

array.toString().toCharArray()

I think may be the correct generic is Map<String,String[]> or Map<String,char[][]>,the generic Map<String,char[]> is confused.

@wenshao

Your response doesn't make sense. You put in something that is the direct cause of the unexpected behavior of FastJson, which needs to be fixed:

array.toString().toCharArray();

The code above is crappy and doesn't capture the right intention.

While Jackson's behavior is much more appreciated:

image

This issue is NOT a question, it is a bug report about a misleading behavior of FastJson.

@wenshao

Thanks for taking this one as a bug, it makes me feel much more confortable with my decision of using FastJson as the built-in JSON library for ActFramework

@greenlaw110
Thank you choose fastjson. I will fix this problem in the next version.

@wenshao
Beautiful! Do you think there is any room for taking the issue #777 ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wizardleeen picture wizardleeen  ·  4Comments

lilijreey picture lilijreey  ·  4Comments

cddesire picture cddesire  ·  3Comments

Ccixyj picture Ccixyj  ·  4Comments

liubailin2017 picture liubailin2017  ·  4Comments