Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ghost opened this issue Aug 14, 2016 · 6 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Aug 14, 2016

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<String,String[]> or Map<String,char[][]>,it will correct.

@wenshao
Copy link
Member

wenshao commented Aug 14, 2016

Get this result because:

array.toString().toCharArray()

@ghost
Copy link
Author

ghost commented Aug 14, 2016

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

@greenlaw110
Copy link

greenlaw110 commented Aug 14, 2016

@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 wenshao added this to the 1.2.17 milestone Aug 25, 2016
@wenshao wenshao added bug and removed question labels Aug 25, 2016
@greenlaw110
Copy link

@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

@wenshao
Copy link
Member

wenshao commented Aug 28, 2016

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

@greenlaw110
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants