如何从JSON中删除第一个和最后一个方括号

时间:2015-08-10 06:27:10

标签: json python-2.7

我将以下JSON存储在Hadoop中,由于JSON中的第一个和最后一个方括号,无法在Hive表中加载它。 Hadoop中存储的JSON文件如下所示

[
  {
    firstname:"kunal",
    lastname:"gupta",
    age:20
  },
  {
    firstname:"Abhishek",
    lastname:"gautam",
    age:20
  },
  {
    firstname:"Neha",
    lastname:"gupta",
    age:20
  }
]

请帮我删除使用Python脚本的第一个和最后一个方括号,以便JSON看起来如下所示: -

{
    firstname:"kunal",
    lastname:"gupta",
    age:20
},
{
    firstname:"Abhishek",
    lastname:"gautam",
    age:20
},
{
    firstname:"Neha",
    lastname:"gupta",
    age:20
}

0 个答案:

没有答案