Sample code for 30+ languages & platforms
Tcl

JSON Hex Encoding

See more JSON Examples

Let's say your JSON contains content that is hex encoded like this: \u05d1\u05d3\u05d9\u05e7

This example shows how to get the decoded string.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set s "{ \"example\": \"\\u05d1\\u05d3\\u05d9\\u05e7\" }"

set json [new_CkJsonObject]

set success [CkJsonObject_Load $json $s]

# When getting the member data, it is automatically decoded.
puts "member data: [CkJsonObject_stringOf $json example]"

# Output:
# member data: בדיק

# When getting the full JSON, it remains encoded. This is expected and intentional.
puts "full JSON: [CkJsonObject_emit $json]"

# Output:
# full JSON: {"example":"\u05d1\u05d3\u05d9\u05e7"}

# To get the full JSON without the encoding, you can decode manually.
set sb [new_CkStringBuilder]

CkJsonObject_EmitSb $json $sb
# The hex encoding used by JSON is utf-8.
CkStringBuilder_Decode $sb "json" "utf-8"

puts [CkStringBuilder_getAsString $sb]

# Output:
# {"example":"בדיק"}

delete_CkJsonObject $json
delete_CkStringBuilder $sb