{
  "id": 9677,
  "title": "JSON errors in Python",
  "url": "/competitions/avito-prohibited-content/discussion/9677",
  "author_name": "",
  "post_date": "2014-07-08T19:05:14.560Z",
  "votes": null,
  "comment_count": 6,
  "views": 4020,
  "content": "<p>When I try to parse attrs using Python's json module, I get ValueError with some examples, for example with those:<br><br></p>\n<p><code>{&quot;&#1058;&#1080;&#1087; &#1086;&#1073;&#1098;&#1103;&#1074;&#1083;&#1077;&#1085;&#1080;&#1103;&quot;:&quot;&#1055;&#1088;&#1086;&#1076;&#1072;&#1084;&quot;, &quot;&#1050;&#1086;&#1083;&#1080;&#1095;&#1077;&#1089;&#1090;&#1074;&#1086; &#1082;&#1086;&#1084;&#1085;&#1072;&#1090;&quot;:&quot;2&quot;, &quot;&#1042;&#1080;&#1076; &#1086;&#1073;&#1098;&#1077;&#1082;&#1090;&#1072;&quot;:&quot;&#1042;&#1090;&#1086;&#1088;&#1080;&#1095;&#1082;&#1072;&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;3&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;&#1053;&#1077; &#1087;&#1077;&#1088;&#1074;&#1099;&#1081; &#1080; &#1085;&#1077; &#1087;&#1086;&#1089;&#1083;&#1077;&#1076;&#1085;&#1080;&#1081;&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;&lt; 5&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;4&quot;, &quot;&#1058;&#1080;&#1087; &#1076;&#1086;&#1084;&#1072;&quot;:&quot;&#1050;&#1080;&#1088;&#1087;&#1080;&#1095;&#1085;&#1099;&#1081;&quot;, &quot;&#1040;&#1076;&#1088;&#1077;&#1089;&quot;:&quot;&#1052;&#1080;&#1088;&#1072; &#1091;&#1083; 28&quot;}<br>{&quot;&#1058;&#1080;&#1087; &#1086;&#1073;&#1098;&#1103;&#1074;&#1083;&#1077;&#1085;&#1080;&#1103;&quot;:&quot;&#1057;&#1076;&#1072;&#1084;&quot;, &quot;&#1057;&#1088;&#1086;&#1082; &#1072;&#1088;&#1077;&#1085;&#1076;&#1099;&quot;:&quot;&#1053;&#1072; &#1076;&#1083;&#1080;&#1090;&#1077;&#1083;&#1100;&#1085;&#1099;&#1081; &#1089;&#1088;&#1086;&#1082;&quot;, &quot;&#1050;&#1086;&#1084;&#1085;&#1072;&#1090; &#1074; &#1082;&#1074;&#1072;&#1088;&#1090;&#1080;&#1088;&#1077;&quot;:&quot;4&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;&#1053;&#1077; &#1087;&#1077;&#1088;&#1074;&#1099;&#1081; &#1080; &#1085;&#1077; &#1087;&#1086;&#1089;&#1083;&#1077;&#1076;&#1085;&#1080;&#1081;&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;3&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;5-8&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;5&quot;, &quot;&#1058;&#1080;&#1087; &#1076;&#1086;&#1084;&#1072;&quot;:&quot;&#1050;&#1080;&#1088;&#1087;&#1080;&#1095;&#1085;&#1099;&#1081;&quot;, &quot;&#1040;&#1076;&#1088;&#1077;&#1089;&quot;:&quot;&#1040;&#1089;&#1072;&#1090;&#1082;&#1080;&#1085;&#1072; &#1091;&#1083; 31&quot;}<br>{&quot;&#1058;&#1080;&#1087; &#1086;&#1073;&#1098;&#1103;&#1074;&#1083;&#1077;&#1085;&#1080;&#1103;&quot;:&quot;&#1055;&#1088;&#1086;&#1076;&#1072;&#1084;&quot;, &quot;&#1050;&#1086;&#1083;&#1080;&#1095;&#1077;&#1089;&#1090;&#1074;&#1086; &#1082;&#1086;&#1084;&#1085;&#1072;&#1090;&quot;:&quot;1&quot;, &quot;&#1042;&#1080;&#1076; &#1086;&#1073;&#1098;&#1077;&#1082;&#1090;&#1072;&quot;:&quot;&#1042;&#1090;&#1086;&#1088;&#1080;&#1095;&#1082;&#1072;&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;&#1053;&#1077; &#1087;&#1077;&#1088;&#1074;&#1099;&#1081; &#1080; &#1085;&#1077; &#1087;&#1086;&#1089;&#1083;&#1077;&#1076;&#1085;&#1080;&#1081;&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;11&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;13-16&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;13&quot;, &quot;&#1058;&#1080;&#1087; &#1076;&#1086;&#1084;&#1072;&quot;:&quot;&#1050;&#1080;&#1088;&#1087;&#1080;&#1095;&#1085;&#1099;&#1081;&quot;, &quot;&#1040;&#1076;&#1088;&#1077;&#1089;&quot;:&quot;&#1053;&#1080;&#1078;&#1085;&#1103;&#1103; &#1044;&#1091;&#1073;&#1088;&#1086;&#1074;&#1072; &#1091;&#1083; 17&quot;}<br><br></code></p>\n<p>However when I copy and paste, it works (at least with some):</p>\n<p><code><br>In [43]: json.loads('{&quot;&#1058;&#1080;&#1087; &#1086;&#1073;&#1098;&#1103;&#1074;&#1083;&#1077;&#1085;&#1080;&#1103;&quot;:&quot;&#1055;&#1088;&#1086;&#1076;&#1072;&#1084;&quot;, &quot;&#1050;&#1086;&#1083;&#1080;&#1095;&#1077;&#1089;&#1090;&#1074;&#1086; &#1082;&#1086;&#1084;&#1085;&#1072;&#1090;&quot;:&quot;1&quot;, &quot;&#1042;&#1080;&#1076; &#1086;&#1073;&#1098;&#1077;&#1082;&#1090;&#1072;&quot;:&quot;&#1042;&#1090;&#1086;&#1088;&#1080;&#1095;&#1082;&#1072;&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;&#1053;&#1077; &#1087;&#1077;&#1088;&#1074;&#1099;&#1081; &#1080; &#1085;&#1077; &#1087;&#1086;&#1089;&#1083;&#1077;&#1076;&#1085;&#1080;&#1081;&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;11&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;13-16&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;13&quot;, &quot;&#1058;&#1080;&#1087; &#1076;&#1086;&#1084;&#1072;&quot;:&quot;&#1050;&#1080;&#1088;&#1087;&#1080;&#1095;&#1085;&#1099;&#1081;&quot;, &quot;&#1040;&#1076;&#1088;&#1077;&#1089;&quot;:&quot;&#1053;&#1080;&#1078;&#1085;&#1103;&#1103; &#1044;&#1091;&#1073;&#1088;&#1086;&#1074;&#1072; &#1091;&#1083;17&quot;}')<br>Out[43]: <br>{u'\\u0410\\u0434\\u0440\\u0435\\u0441': u'\\u041d\\u0438\\u0436\\u043d\\u044f\\u044f \\u0414\\u0443\\u0431\\u0440\\u043e\\u0432\\u0430 \\u0443\\u043b17',<br> u'\\u0412\\u0438\\u0434 \\u043e\\u0431\\u044a\\u0435\\u043a\\u0442\\u0430': u'\\u0412\\u0442\\u043e\\u0440\\u0438\\u0447\\u043a\\u0430',<br> u'\\u041a\\u043e\\u043b\\u0438\\u0447\\u0435\\u0441\\u0442\\u0432\\u043e \\u043a\\u043e\\u043c\\u043d\\u0430\\u0442': u'1',<br> u'\\u0422\\u0438\\u043f \\u0434\\u043e\\u043c\\u0430': u'\\u041a\\u0438\\u0440\\u043f\\u0438\\u0447\\u043d\\u044b\\u0439',<br> u'\\u0422\\u0438\\u043f \\u043e\\u0431\\u044a\\u044f\\u0432\\u043b\\u0435\\u043d\\u0438\\u044f': u'\\u041f\\u0440\\u043e\\u0434\\u0430\\u043c',<br> u'\\u042d\\u0442\\u0430\\u0436': u'11',<br> u'\\u042d\\u0442\\u0430\\u0436\\u0435\\u0439 \\u0432 \\u0434\\u043e\\u043c\\u0435': u'13'}<br><br></code></p>\n<p>Any ideas?</p>",
  "messages": [
    {
      "id": "50148",
      "postDate": "07/08/2014 19:05:14",
      "content": "<p>When I try to parse attrs using Python's json module, I get ValueError with some examples, for example with those:<br><br></p>\n<p><code>{&quot;&#1058;&#1080;&#1087; &#1086;&#1073;&#1098;&#1103;&#1074;&#1083;&#1077;&#1085;&#1080;&#1103;&quot;:&quot;&#1055;&#1088;&#1086;&#1076;&#1072;&#1084;&quot;, &quot;&#1050;&#1086;&#1083;&#1080;&#1095;&#1077;&#1089;&#1090;&#1074;&#1086; &#1082;&#1086;&#1084;&#1085;&#1072;&#1090;&quot;:&quot;2&quot;, &quot;&#1042;&#1080;&#1076; &#1086;&#1073;&#1098;&#1077;&#1082;&#1090;&#1072;&quot;:&quot;&#1042;&#1090;&#1086;&#1088;&#1080;&#1095;&#1082;&#1072;&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;3&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;&#1053;&#1077; &#1087;&#1077;&#1088;&#1074;&#1099;&#1081; &#1080; &#1085;&#1077; &#1087;&#1086;&#1089;&#1083;&#1077;&#1076;&#1085;&#1080;&#1081;&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;&lt; 5&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;4&quot;, &quot;&#1058;&#1080;&#1087; &#1076;&#1086;&#1084;&#1072;&quot;:&quot;&#1050;&#1080;&#1088;&#1087;&#1080;&#1095;&#1085;&#1099;&#1081;&quot;, &quot;&#1040;&#1076;&#1088;&#1077;&#1089;&quot;:&quot;&#1052;&#1080;&#1088;&#1072; &#1091;&#1083; 28&quot;}<br>{&quot;&#1058;&#1080;&#1087; &#1086;&#1073;&#1098;&#1103;&#1074;&#1083;&#1077;&#1085;&#1080;&#1103;&quot;:&quot;&#1057;&#1076;&#1072;&#1084;&quot;, &quot;&#1057;&#1088;&#1086;&#1082; &#1072;&#1088;&#1077;&#1085;&#1076;&#1099;&quot;:&quot;&#1053;&#1072; &#1076;&#1083;&#1080;&#1090;&#1077;&#1083;&#1100;&#1085;&#1099;&#1081; &#1089;&#1088;&#1086;&#1082;&quot;, &quot;&#1050;&#1086;&#1084;&#1085;&#1072;&#1090; &#1074; &#1082;&#1074;&#1072;&#1088;&#1090;&#1080;&#1088;&#1077;&quot;:&quot;4&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;&#1053;&#1077; &#1087;&#1077;&#1088;&#1074;&#1099;&#1081; &#1080; &#1085;&#1077; &#1087;&#1086;&#1089;&#1083;&#1077;&#1076;&#1085;&#1080;&#1081;&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;3&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;5-8&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;5&quot;, &quot;&#1058;&#1080;&#1087; &#1076;&#1086;&#1084;&#1072;&quot;:&quot;&#1050;&#1080;&#1088;&#1087;&#1080;&#1095;&#1085;&#1099;&#1081;&quot;, &quot;&#1040;&#1076;&#1088;&#1077;&#1089;&quot;:&quot;&#1040;&#1089;&#1072;&#1090;&#1082;&#1080;&#1085;&#1072; &#1091;&#1083; 31&quot;}<br>{&quot;&#1058;&#1080;&#1087; &#1086;&#1073;&#1098;&#1103;&#1074;&#1083;&#1077;&#1085;&#1080;&#1103;&quot;:&quot;&#1055;&#1088;&#1086;&#1076;&#1072;&#1084;&quot;, &quot;&#1050;&#1086;&#1083;&#1080;&#1095;&#1077;&#1089;&#1090;&#1074;&#1086; &#1082;&#1086;&#1084;&#1085;&#1072;&#1090;&quot;:&quot;1&quot;, &quot;&#1042;&#1080;&#1076; &#1086;&#1073;&#1098;&#1077;&#1082;&#1090;&#1072;&quot;:&quot;&#1042;&#1090;&#1086;&#1088;&#1080;&#1095;&#1082;&#1072;&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;&#1053;&#1077; &#1087;&#1077;&#1088;&#1074;&#1099;&#1081; &#1080; &#1085;&#1077; &#1087;&#1086;&#1089;&#1083;&#1077;&#1076;&#1085;&#1080;&#1081;&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;11&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;13-16&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;13&quot;, &quot;&#1058;&#1080;&#1087; &#1076;&#1086;&#1084;&#1072;&quot;:&quot;&#1050;&#1080;&#1088;&#1087;&#1080;&#1095;&#1085;&#1099;&#1081;&quot;, &quot;&#1040;&#1076;&#1088;&#1077;&#1089;&quot;:&quot;&#1053;&#1080;&#1078;&#1085;&#1103;&#1103; &#1044;&#1091;&#1073;&#1088;&#1086;&#1074;&#1072; &#1091;&#1083; 17&quot;}<br><br></code></p>\n<p>However when I copy and paste, it works (at least with some):</p>\n<p><code><br>In [43]: json.loads('{&quot;&#1058;&#1080;&#1087; &#1086;&#1073;&#1098;&#1103;&#1074;&#1083;&#1077;&#1085;&#1080;&#1103;&quot;:&quot;&#1055;&#1088;&#1086;&#1076;&#1072;&#1084;&quot;, &quot;&#1050;&#1086;&#1083;&#1080;&#1095;&#1077;&#1089;&#1090;&#1074;&#1086; &#1082;&#1086;&#1084;&#1085;&#1072;&#1090;&quot;:&quot;1&quot;, &quot;&#1042;&#1080;&#1076; &#1086;&#1073;&#1098;&#1077;&#1082;&#1090;&#1072;&quot;:&quot;&#1042;&#1090;&#1086;&#1088;&#1080;&#1095;&#1082;&#1072;&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;&#1053;&#1077; &#1087;&#1077;&#1088;&#1074;&#1099;&#1081; &#1080; &#1085;&#1077; &#1087;&#1086;&#1089;&#1083;&#1077;&#1076;&#1085;&#1080;&#1081;&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&quot;:&quot;11&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;13-16&quot;, &quot;&#1069;&#1090;&#1072;&#1078;&#1077;&#1081; &#1074; &#1076;&#1086;&#1084;&#1077;&quot;:&quot;13&quot;, &quot;&#1058;&#1080;&#1087; &#1076;&#1086;&#1084;&#1072;&quot;:&quot;&#1050;&#1080;&#1088;&#1087;&#1080;&#1095;&#1085;&#1099;&#1081;&quot;, &quot;&#1040;&#1076;&#1088;&#1077;&#1089;&quot;:&quot;&#1053;&#1080;&#1078;&#1085;&#1103;&#1103; &#1044;&#1091;&#1073;&#1088;&#1086;&#1074;&#1072; &#1091;&#1083;17&quot;}')<br>Out[43]: <br>{u'\\u0410\\u0434\\u0440\\u0435\\u0441': u'\\u041d\\u0438\\u0436\\u043d\\u044f\\u044f \\u0414\\u0443\\u0431\\u0440\\u043e\\u0432\\u0430 \\u0443\\u043b17',<br> u'\\u0412\\u0438\\u0434 \\u043e\\u0431\\u044a\\u0435\\u043a\\u0442\\u0430': u'\\u0412\\u0442\\u043e\\u0440\\u0438\\u0447\\u043a\\u0430',<br> u'\\u041a\\u043e\\u043b\\u0438\\u0447\\u0435\\u0441\\u0442\\u0432\\u043e \\u043a\\u043e\\u043c\\u043d\\u0430\\u0442': u'1',<br> u'\\u0422\\u0438\\u043f \\u0434\\u043e\\u043c\\u0430': u'\\u041a\\u0438\\u0440\\u043f\\u0438\\u0447\\u043d\\u044b\\u0439',<br> u'\\u0422\\u0438\\u043f \\u043e\\u0431\\u044a\\u044f\\u0432\\u043b\\u0435\\u043d\\u0438\\u044f': u'\\u041f\\u0440\\u043e\\u0434\\u0430\\u043c',<br> u'\\u042d\\u0442\\u0430\\u0436': u'11',<br> u'\\u042d\\u0442\\u0430\\u0436\\u0435\\u0439 \\u0432 \\u0434\\u043e\\u043c\\u0435': u'13'}<br><br></code></p>\n<p>Any ideas?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "51075",
      "postDate": "07/23/2014 00:49:14",
      "content": "<p>How about try `eval` them into python dictionaries&nbsp;directly?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "51081",
      "postDate": "07/23/2014 05:21:22",
      "content": "<p>Tried that to start with.<br><br>EDIT: Turns out that a combination of json.loads() and eval() works. Here's a demo:<br><br>https://github.com/zygmuntz/kaggle-avito</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "51083",
      "postDate": "07/23/2014 08:15:26",
      "content": "<p>Handling Cyrillic letters in Python is quite messy. I wish all modern programming languages were Cyrillic-based. Then everyone by now would ask on forums how to make the language tackle this weird Latin alphabet.</p>\n<p>Try putting this at the beginning of your script (before all imports):</p>\n<p># -*- coding: utf-8 -*-</p>\n<p>Dunno if this works in iPython notebooks though.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "51111",
      "postDate": "07/23/2014 23:56:17",
      "content": "<p>For people using pandas, `attrs` can be converted to a column of dictionaries by:</p>\n<p><code>import pandas as pd</code></p>\n<p><code></code><code>train =&nbsp;pd.read_csv('avito_train.tsv', sep='\\t')</code></p>\n<p><code>train['attrs'] = train['attrs'].fillna('{}').astype(str).apply(lambda x:eval(x.replace('/&quot;', '\\'').replace(&quot;'}&quot;, '&quot;}')))</code></p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "51117",
      "postDate": "07/24/2014 06:18:56",
      "content": "<p>Hello, there is another way to convert attrs to dictionary using&nbsp;json:</p>\n<p>json.loads(re.sub('/\\&quot;(?!(,\\s&quot;|}))','\\\\&quot;',item[&quot;attrs&quot;]).replace(&quot;\\t&quot;,&quot; &quot;).replace(&quot;\\n&quot;,&quot; &quot;)) if len(item[&quot;attrs&quot;])&gt;0 else {}</p>\n<p>This is tested and works well.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "52498",
      "postDate": "08/27/2014 10:15:41",
      "content": "<p>Perfect thanks</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 51075,
      "author_name": "apophenia",
      "author_url": "",
      "post_date": "07/23/2014 00:49:14",
      "content": "<p>How about try `eval` them into python dictionaries&nbsp;directly?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 51081,
      "author_name": "zygmunt",
      "author_url": "",
      "post_date": "07/23/2014 05:21:22",
      "content": "<p>Tried that to start with.<br><br>EDIT: Turns out that a combination of json.loads() and eval() works. Here's a demo:<br><br>https://github.com/zygmuntz/kaggle-avito</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 51083,
      "author_name": "yetmorephunk",
      "author_url": "",
      "post_date": "07/23/2014 08:15:26",
      "content": "<p>Handling Cyrillic letters in Python is quite messy. I wish all modern programming languages were Cyrillic-based. Then everyone by now would ask on forums how to make the language tackle this weird Latin alphabet.</p>\n<p>Try putting this at the beginning of your script (before all imports):</p>\n<p># -*- coding: utf-8 -*-</p>\n<p>Dunno if this works in iPython notebooks though.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 51111,
      "author_name": "apophenia",
      "author_url": "",
      "post_date": "07/23/2014 23:56:17",
      "content": "<p>For people using pandas, `attrs` can be converted to a column of dictionaries by:</p>\n<p><code>import pandas as pd</code></p>\n<p><code></code><code>train =&nbsp;pd.read_csv('avito_train.tsv', sep='\\t')</code></p>\n<p><code>train['attrs'] = train['attrs'].fillna('{}').astype(str).apply(lambda x:eval(x.replace('/&quot;', '\\'').replace(&quot;'}&quot;, '&quot;}')))</code></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 51117,
      "author_name": "vasilyleksin",
      "author_url": "",
      "post_date": "07/24/2014 06:18:56",
      "content": "<p>Hello, there is another way to convert attrs to dictionary using&nbsp;json:</p>\n<p>json.loads(re.sub('/\\&quot;(?!(,\\s&quot;|}))','\\\\&quot;',item[&quot;attrs&quot;]).replace(&quot;\\t&quot;,&quot; &quot;).replace(&quot;\\n&quot;,&quot; &quot;)) if len(item[&quot;attrs&quot;])&gt;0 else {}</p>\n<p>This is tested and works well.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 52498,
      "author_name": "delijati80",
      "author_url": "",
      "post_date": "08/27/2014 10:15:41",
      "content": "<p>Perfect thanks</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "50148": "",
    "51075": "",
    "51081": "",
    "51083": "",
    "51111": "",
    "51117": "",
    "52498": ""
  },
  "source": "meta"
}