line/line-bot-sdk-python

`to_json` method of Flex Object escapes Japanese characters

nozomiyamada opened this issue · 3 comments

Thank you for Developer team!

I really appreciate the new version (v3) of SDK. Especially, introducing each class of Flex Components makes it easier to code in Python.

I am facing a problem that to_json() method escapes non-ascii characters such as Japanese. For example, あいうえお becomes "\\u3042\\u3044\\u3046\\u3048\\u304a" in output JSON.

Actually it does not matter when I send a Flex Message via API, however it does not display correctly in Flex Message Simulator.

Screenshot 2024-01-08 at 05 02 33

It may be a problem of Flex Message Simulator. Now I overwrite the source code and set ensure_ascii=False in json.dumps method in order not to escape the characters.

linebot/v3/messaging/models/flex_bubble.py
Screenshot 2024-01-08 at 05 10 02

However, there are many classes regarding Flex Object and it is somehow troublesome to overwrite all of them.

Is there any good solutions or future improvement? I am looking forward to your response. Thank You.

Regards,

Sorry, it's my fault. I found the solution by myself.
It's just to print the JSON string so that \ would not become double.
Flex Message Simulator works correctly even if string is escaped. I'm really sorry for blaming it 😂

Thank you for using line-bot-sdk-python, @nozomiyamada!
Was this question resolved finally?

Yes the problem resolved, thanks.
I really like the v3 version of line-bot-sdk, I appreciate the developer teams! 😄