1. YU CHUN
  2. PowerBuilder
  3. Wednesday, 19 June 2019

I get a JSON like :

{"data": {"name": "\u9673\u6cf0\u5c71", "coupon": [], "is_active": true, "sex": "male", "birthday": "2019-05-15T16:00:00Z", "mobile_number": "+88696631", "balance": 10}}

 

name is Chinese

What function can help me convert it to Chinese?

Accepted Answer
Mark Lee Accepted Answer Pending Moderation
2
Votes
Undo

Hi Yu,

This issue is caused due to that the current JSON you retrieved is Unicode.

There are two suggestions for you:

  1. Turn the JSON format to UTF-8 in the server like:

{"data": {"name": "陳泰山", "coupon": [], "is_active": true, "sex": "male", "birthday": "2019-05-15t16:00:00z", "mobile_number": "+88696631", "balance": 10}}

You can refer to the link below:

http://www.bejson.com/convert/unicode_chinese/

 

  1. Regenerate JSON in PB client or get that value directly, you can refer to the code below:

 

//method 1
lnv_JsonParser = Create JsonParser
ls_Json = '{"data": {"name": "\u9673\u6cf0\u5c71", "coupon": [], "is_active": true, "sex": "male", "birthday": "2019-05-15T16:00:00Z", "mobile_number": "+88696631", "balance": 10}}'
ls_Error = lnv_JsonParser.LoadString(ls_Json)
if Len(ls_Error) > 0 then
 	MessageBox("Error", ls_Error)
end if

ll_RootObject = lnv_JsonParser.GetRootItem()
ll_number_item = lnv_jsonparser.getchilditem(ll_RootObject, 1)
ls_name = lnv_JsonParser.GetItemString(ll_number_item, "name")
//messagebox("ls_name",ls_name)

//method 2
JSONPackage   lnv_JsonGenerator
lnv_JsonGenerator = create JSONPackage 
ls_Json = '{"data": {"name": "\u9673\u6cf0\u5c71", "coupon": [], "is_active": true, "sex": "male", "birthday": "2019-05-15T16:00:00Z", "mobile_number": "+88696631", "balance": 10}}'
lnv_JsonGenerator.LoadString(ls_Json)
ls_data = lnv_JsonGenerator.getjsonstring( )

 

Regards,

Mark Lee

Attachments (1)
Comment
There are no comments made yet.
  1. Wednesday, 19 June 2019
  2. PowerBuilder
  3. # Permalink
YU CHUN Accepted Answer Pending Moderation
0
Votes
Undo

It can work, thank your help.

Comment
There are no comments made yet.
  1. Wednesday, 19 June 2019
  2. PowerBuilder
  3. # 1
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.