如何将具有唯一标识符的json解析为表格格式?

时间:2018-03-29 17:31:34

标签: json mongodb jsonparser

这是我要解析的json文件。我在文件夹中有一堆这样的文件,我需要将它们解析成表格格式。

    {
  "block-v1:SampleData-type@chapter+block@14a0423ddf4a4d90926fb348e86a6232": {
    "category": "chapter", 
    "children": [
      "block-v1:SampleData-type@sequential+block@0fd2ac771bd141f384b8a3c628207d1d", 
      //similar sequential blocks
    ], 
    "metadata": {
      "display_name": "XYZZ", 
      "start": "2017-02-13T07:00:00Z"
    }
  }, 
  "block-v1:SampleData-type@chapter+block@46a4c70e4ce94fa5b99b15138d656291": {
    "category": "chapter", 
    "children": [
      "block-v1:SampleData-type@sequential+block@98d28f78d0524360bd51ae57db438c0b"
    ], 
    "metadata": {
      "display_name": "QAQA", 
      "visible_to_staff_only": true
    }
  },
  "block-v1:SampleData-type@discussion+block@3214a8c65ced4efdaaff047ca4854111": {
    "category": "discussion", 
    "children": [], 
    "metadata": {
      "discussion_id": "3fb8fc6eb4f742e7567e8e488789d3132270c4f0", 
      "discussion_target": "MMMMM", 
      "display_name": "MMMMM"
    }
  }
  //similar more category blocks
  // start of all sequential blocks
  "block-v1:SampleData-type@sequential+block@0fd2ac771bd141f384b8a3c628207d1d": {
    "category": "sequential", 
    "children": [
      "block-v1:SampleData-type@vertical+block@aba5c5f4ea104d91bb74f6ce8504fb9d", 
      "block-v1:SampleData-type@vertical+block@973374916a1b4960bb04125906be5350"
    ], 
    "metadata": {
      "display_name": "XYZZ--QQQQ"
    }
  }, 
  // end of all sequential blocks
  // start of all vertical blocks
  "block-v1:SampleData-type@vertical+block@aba5c5f4ea104d91bb74f6ce8504fb9d": {
    "category": "vertical", 
    "children": [
      "block-v1:SampleData-type@video+block@f03bafe28e124a41bb6d86f921ec9d76"
    ], 
    "metadata": {
      "display_name": "XYZZ--QQQQ--AAAA"
    }
  }, 
  "block-v1:SampleData-type@vertical+block@973374916a1b4960bb04125906be5350": {
    "category": "vertical", 
    "children": [
      "block-v1:SampleData-type@html+block@4730907c48e947d1847be66944bbd30d"
    ], 
    "metadata": {
      "display_name": "XYZZ--QQQQ--BBBB"
    }
  }, 
  //end of all vertical blocks
  //
  //
  //
  //similar sequential and vertical blocks for other chapters
  //REMOVE COMMENTS WHILE TRYING TO PARSE THIS DATA
  //
  //
  }

需要获得以下输出:

output in tabular format

我的问题是,这个带有唯一标识符的数据是什么?并且,有没有现成的工具将这些数据解析为表格格式? 或建议为这些数据创建自定义解析器?

1 个答案:

答案 0 :(得分:0)

  

有没有现成的工具可以将这些数据解析为表格格式?

是:jq https://stedolan.github.io/jq/