2

Python 2.7.13 Windows AMD64

Having trouble handling a JSON file using \u Unicode format.

Test Case

import json

testJ = json.load(open("simple.json"))
print(testJ['a'])

simple.json

{"a": "\u00AA"}

output

ª

desired output

ª

How do I get the desired output using Python? If I use jq tool

jq ".a" < simple.json

I get the expected output

Robᵩ
  • 143,876
  • 16
  • 205
  • 276
Carlos Rendon
  • 6,006
  • 5
  • 31
  • 49
  • Sounds like a locale mismatch. You want to make sure Python is configured to use UTF-8 on standard output. This is a very common FAQ. – tripleee Feb 01 '17 at 04:35

1 Answers1

0

Not sure what is the IDE that you are using.

But if you want to print out unicode characters on Window command lines, try this:
C:\>chcp 65001
It will support the display of UTF-8 encoded text.

Tri M. Le
  • 53
  • 3