Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how json dump Japanese
#2
import json
my_data = '{"some_japanese_text":"このコーディネートのスタイリストについて"}'

# load it in a dict
json_data = json.loads(my_data, encoding='utf-8')
print(type(json_data))

# print the sting
print(json.dumps(json_data, indent=2, ensure_ascii=False))

# or write it to foo.json
with open('foo.json', 'w') as jf:
    json.dump(json_data, jf, indent=2, ensure_ascii=False)
Output:
<class 'dict'> { "some_japanese_text": "このコーディネートのスタイリストについて" }
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
how json dump Japanese - by yunkai - Dec-22-2018, 05:23 PM
RE: how json dump Japanese - by buran - Dec-22-2018, 06:23 PM
RE: how json dump Japanese - by vishalhule - Mar-17-2020, 07:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  JSON Dump and JSON Load foxholenoob 8 1,179 Oct-12-2023, 07:21 AM
Last Post: foxholenoob
  UnicodeEncodeError - Dealing with Japanese Characters fioranosnake 2 2,529 Jul-07-2022, 08:43 PM
Last Post: fioranosnake
  Python html herf to json dump help paulfearn100 0 2,065 Mar-03-2020, 09:16 PM
Last Post: paulfearn100
  print python json dump onto multiple lines lhailey 2 19,962 Mar-02-2020, 12:47 PM
Last Post: vishalhule
  creating hex dump modifying program ensoniq 3 2,664 Oct-14-2019, 08:21 AM
Last Post: Larz60+
  Type error: dump() missing 1 required positional argument: fp jaycuff13 2 22,064 Jul-13-2019, 10:21 AM
Last Post: jaycuff13
  Using pickle.dump Friend 1 2,973 Feb-15-2019, 04:39 PM
Last Post: metulburr
  tf.gfile.FastGFile error unicode ( japanese characters ) majinbuu 2 3,110 May-13-2018, 02:11 PM
Last Post: majinbuu

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020