go在線工具集
首頁
搜索
致boss

json轉esmapping工具
5  |   |   |  1

功能介紹

1.支持解析嵌套 json 串, 根據遞迴進行解析嵌套對象
2.支持解析數組 json 串, 會取數組中第一個 json 串進行解析
3.檢查 json 串格式是否正確, 輸出錯誤的位置

示例

解析嵌套 json 串

{
    "name": "test",
    "age": 10,
    "addr": "四川成都",
    "cls_info": [
        {
            "name": "籃球班",
            "teacher": "張老師"
        },
        {
            "name": "美術班",
            "teacher": "李老師"
        }
    ]
}

處理後

{
  "mappings": {
    "properties": {
      "name": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "age": {
        "type": "integer"
      },
      "addr": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "cls_info": {
        "properties": {
          "name": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "teacher": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    }
  }
}

直接解析數組 json 串

[
    {
        "name": "test",
        "age": 10,
        "addr": "四川成都",
        "cls_info": [
            {
                "name": "籃球班",
                "teacher": "張老師"
            },
            {
                "name": "美術班",
                "teacher": "李老師"
            }
        ]
    },
    {
        "name": "test2",
        "age": 10,
        "addr": "四川成都",
        "cls_info": [
            {
                "name": "籃球班",
                "teacher": "張老師"
            },
            {
                "name": "美術班",
                "teacher": "李老師"
            }
        ]
    }
]

處理後

{
  "mappings": {
    "properties": {
      "name": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "age": {
        "type": "integer"
      },
      "addr": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "cls_info": {
        "properties": {
          "name": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "teacher": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    }
  }
}