拆分json文件..在花括号之间提取数据

时间:2014-03-19 06:19:19

标签: regex json sed awk grep

我有一个json文件。我想将该文件分成不同的部分..

以下是我的文件内容。 我想基于大括号{},

拆分内容
"1010320": {
    "abc": [
        "1012220", 
        "hiiiiiiiii."
    ], 
    "xyz": "Describe"
}, 
"1012757": {
    "pqr": [
        "1013757", 
        "x"
    ]
}, 
"1014220": {
    "abc": [
        "1018420", 
        "sooooo"
    ], 
    "answer": "4th"
}, 
"1019660": {
    "abc": [
        "1031920", 
        "welcome"
    ], 
    "xyz": "Describing&Interpreting"
}, 
"1034280": {
    "abc": [
        "1040560", 
        "Ok..."
    ], 
    "nop": "Student Question"
}, 

输出应为:

1)     "abc": [
            "1012220", 
            "hiiiiiiiii."
        ], 
        "xyz": "Describe"


2)         "pqr": [
            "1013757", 
            "x"
        ]


3)         "abc": [
            "1018420", 
            "sooooo"
        ], 
        "answer": "4th"

plz .. help ..

1 个答案:

答案 0 :(得分:0)

我认为这对你有用

(?<=\{)\n\s+((?:[\n]+|.*)+?)\n\}

正则表达式演示:http://regex101.com/r/rS3wI5