doulierong0334
2017-10-23 02:53
采纳率: 100%
浏览 102
已采纳

在Golang中解析JSON以绘制多边形

I'm parsing a large JSON file in Go where I need to take only specific items from the JSON.

It's usually a very large file, but eventually, it becomes this:

"textAnnotations": [
    {
        "boundingPoly": {
            "vertices": [
                {
                    "x": 136,
                    "y": 119
                },
                {
                    "x": 5606,
                    "y": 119
                },
                {
                    "x": 5606,
                    "y": 3985
                },
                {
                    "x": 136,
                    "y": 3985
                }
            ]
        },
        "description": "Description",
        "locale": "en"
    },
    {
        "boundingPoly": {
            "vertices": [
                {
                    "x": 3420,
                    "y": 122
                },
                {
                    "x": 3439,
                    "y": 122
                },
                {
                    "x": 3439,
                    "y": 144
                },
                {
                    "x": 3420,
                    "y": 144
                }
            ]
        },
        "description": "10"
    },
    {
        "boundingPoly": {
            "vertices": [
                {
                    "x": 4106,
                    "y": 119
                },
                {
                    "x": 4128,
                    "y": 119
                },
                {
                    "x": 4128,
                    "y": 141
                },
                {
                    "x": 4106,
                    "y": 141
                }
            ]
        },
        "description": "12"
    },

I need to take the vertices and description of all of the "boundingPoly"'s in that are within "textAnnotations". I've looked at a few JSON parsing libraries but none seem to do exactly what I'm asking for.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题