json.loads with cyrillic string

27 views
Skip to first unread message

Константин Комков

unread,
Jun 4, 2019, 8:03:31 AM6/4/19
to web...@googlegroups.com
Hello! As I think my question is simple, but I don't find solution in internet yet. How can I get cyrillic symbols from that string:
{"fo":["очная","очная","очная"],"fac":["Садоводства и ландшафтной архитектуры","Садоводства и ландшафтной архитектуры","Технологический"],"dir":["Садоводство","Ландшафтная архитектура","Технология производства и переработки сельскохозяйственной продукции"],"cg_id":["27","31","30"],"comp_group":["Садоводство","Ландшафтная архитектура","Технология производства и переработки сельскохозяйственной продукции"],"bud":["Да","Да","Да"]}
I do
b = json.loads(a)
and get
{u'cg_id': [u'27', u'31', u'30'], u'comp_group': [u'\u0421\u0430\u0434\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e', u'\u041b\u0430\u043d\u0434\u0448\u0430\u0444\u0442\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430', u'\u0422\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u0438 \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0435\u043b\u044c\u0441\u043a\u043e\u0445\u043e\u0437\u044f\u0439\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0446\u0438\u0438'], u'dir': [u'\u0421\u0430\u0434\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e', u'\u041b\u0430\u043d\u0434\u0448\u0430\u0444\u0442\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430', u'\u0422\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u0438 \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0435\u043b\u044c\u0441\u043a\u043e\u0445\u043e\u0437\u044f\u0439\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0446\u0438\u0438'], u'fac': [u'\u0421\u0430\u0434\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u0438 \u043b\u0430\u043d\u0434\u0448\u0430\u0444\u0442\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b', u'\u0421\u0430\u0434\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u0438 \u043b\u0430\u043d\u0434\u0448\u0430\u0444\u0442\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b', u'\u0422\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439'], u'bud': [u'\u0414\u0430', u'\u0414\u0430', u'\u0414\u0430'], u'fo': [u'\u043e\u0447\u043d\u0430\u044f', u'\u043e\u0447\u043d\u0430\u044f', u'\u043e\u0447\u043d\u0430\u044f']}
P.S.
b.get('fac')[0]
I get
Садоводства и ландшафтной архитектуры
Why so?





Val K

unread,
Jun 4, 2019, 9:46:21 AM6/4/19
to web2py-users
As far as I understand, strings are displayed in ascii format in the context of objects. What is confusing you?

Константин Комков

unread,
Jun 4, 2019, 9:51:41 AM6/4/19
to web2py-users
Now is nothing, but I thought if I do b.get('fac')[0] I got something like u'\u0421\u0430\u0434\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 \u0438 \u043b\u0430\u043d\u0434\u0448\u0430\u0444\u0442\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b' .

Val K

unread,
Jun 4, 2019, 9:53:12 AM6/4/19
to web2py-users
In python2 it is so

Val K

unread,
Jun 4, 2019, 10:01:01 AM6/4/19
to web2py-users
it is maybe not convenient when storing json as text file, to solve this you can pass ensure_ascii=False to json.dumps

Константин Комков

unread,
Jun 4, 2019, 10:32:03 AM6/4/19
to web...@googlegroups.com
Val K, yes, but I get json string from client js. 

вт, 4 июн. 2019 г., 17:01 Val K <valq...@gmail.com>:
it is maybe not convenient when storing json as text file, to solve this you can pass ensure_ascii=False to json.dumps

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/Jf0nxpP6w2M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/ef98ecd7-0a13-49f7-b982-b4b5c7acbce2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages