about SBC String Serialize

4 views
Skip to first unread message

NHSoft.YHW

unread,
Jan 15, 2009, 3:25:15 AM1/15/09
to jabsorb-user
Hi,

when I serialize SBC sting using jabsorb 1.3, it has strange problem.

test code:

public static void main(String[] args) throws Exception {
Map map = new HashMap();
map.put("SBC case", "—");
JSONObject json = new JSONObject(map);
String jsonStr = json.toString();
System.out.println(jsonStr);
}

but print string is {"SBC case":"\u2014"}, i think that the proper
result is {"SBC case":"—"}

it is jabsorb's bug?

thanks.

Russell Jones

unread,
Jan 15, 2009, 3:45:27 AM1/15/09
to jabsor...@googlegroups.com
I get the following in firebug

a="\u2014"
b="—"
a==b
true

So, AIUI, from the perspective of JSON, if not Java, the two are equivalent.

NHSoft.YHW

unread,
Jan 15, 2009, 6:59:36 AM1/15/09
to jabsorb-user
the result looks strange when the string contains ASCII chars, chinese
char and SBC char:

public static void main(String[] args) throws Exception {
Map map = new HashMap();
map.put("MixedChars", "中文--jabsorb");
JSONObject json = new JSONObject(map);
String jsonStr = json.toString();
System.out.println(jsonStr);
}

run the code, the printed result string as:
{"MixedChars":"中文\u2014jabsorb"}

so i want to know how deserialize the json string in my client side,my
client side write in delphi.



On Jan 15, 4:45 pm, Russell Jones <russell.jo...@careers.ox.ac.uk>
wrote:
> I get the following in firebug
>
> a="\u2014"
> b="--"
> a==b
> true
>
> So, AIUI, from the perspective of JSON, if not Java, the two are equivalent.
>
> NHSoft.YHW wrote:
> > Hi,
>
> > when I serialize SBC sting using jabsorb 1.3, it has strange problem.
>
> > test code:
>
> > public static void main(String[] args) throws Exception {
> > Map map = new HashMap();
> > map.put("SBC case", "--");
> > JSONObject json = new JSONObject(map);
> > String jsonStr = json.toString();
> > System.out.println(jsonStr);
> > }
>
> > but print string is {"SBC case":"\u2014"}, i think that the proper
> > result is {"SBC case":"--"}
Reply all
Reply to author
Forward
0 new messages