Xbase++
Xbase++
JSON Hex Encoding
See more JSON Examples
Let's say your JSON contains content that is hex encoded like this: \u05d1\u05d3\u05d9\u05e7This example shows how to get the decoded string.
Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL s
LOCAL oJson
LOCAL oSb
nSuccess := 0
s := '{ "example": "\u05d1\u05d3\u05d9\u05e7" }'
oJson := CreateObject("Chilkat.JsonObject")
nSuccess := oJson:Load(s)
// When getting the member data, it is automatically decoded.
? "member data: " + oJson:StringOf("example")
// Output:
// member data: בדיק
// When getting the full JSON, it remains encoded. This is expected and intentional.
? "full JSON: " + oJson:Emit()
// Output:
// full JSON: {"example":"\u05d1\u05d3\u05d9\u05e7"}
// To get the full JSON without the encoding, you can decode manually.
oSb := CreateObject("Chilkat.StringBuilder")
oJson:EmitSb(oSb)
// The hex encoding used by JSON is utf-8.
oSb:Decode("json", "utf-8")
? oSb:GetAsString()
// Output:
// {"example":"בדיק"}
oJson:destroy()
oSb:destroy()