0

我在文本文件中有 json,我喜欢在我的情况下将它们嵌入到字符串中 cpp 是否有任何工具或实用程序可以做到这一点?例如,我有这么长的 json,我喜欢与有效字符串一致。

{
    "rigidBodies": [
        {
            "name": "car_test_mapping",
            "imagePath": "car_body_test.png",
            "origin": {
                "x": 0,
                "y": 0
            },
            "polygons": [
                [
                    {
                        "x": 0.782500028610229,
                        "y": 0.21000000834465
                    },
                    {
                        "x": 0.727500081062317,
                        "y": 0.340000003576279
                    },
                    {
                        "x": 0.179999947547913,
                        "y": 0.422500014305115
                    },
                    {
                        "x": 0.179999947547913,
                        "y": 0.260000020265579
                    }
                ],
                [
                    {
                        "x": 0.179999947547913,
                        "y": 0.260000020265579
                    },
                    {
                        "x": 0.00249993801116943,
                        "y": 0.265000015497208
                    },
                    {
                        "x": 0,
                        "y": -0.00499993562698364
                    },
                    {
                        "x": 0.992500066757202,
                        "y": -0.00499993562698364
                    },
                    {
                        "x": 0.990000009536743,
                        "y": 0.1875
                    },
                    {
                        "x": 0.782500028610229,
                        "y": 0.21000000834465
                    }
                ]
            ],
            "circles": [],
            "shapes": [
                {
                    "type": "POLYGON",
                    "vertices": [
                        {
                            "x": 0.00249993801116943,
                            "y": 0.265000015497208
                        },
                        {
                            "x": 0.179999947547913,
                            "y": 0.260000020265579
                        },
                        {
                            "x": 0.179999947547913,
                            "y": 0.422500014305115
                        },
                        {
                            "x": 0.727500081062317,
                            "y": 0.340000003576279
                        },
                        {
                            "x": 0.782500028610229,
                            "y": 0.21000000834465
                        },
                        {
                            "x": 0.990000009536743,
                            "y": 0.1875
                        },
                        {
                            "x": 0.992500066757202,
                            "y": -0.00499993562698364
                        },
                        {
                            "x": 0,
                            "y": -0.00499993562698364
                        }
                    ]
                }
            ]
        }
    ],
    "dynamicObjects": []
}
4

1 回答 1

1

您必须使用 JSON.stringify.see文档

于 2013-11-10T08:59:22.707 回答