相关疑难解决方法(0)

用C++创建一个json数组

所以我试图动态地在c ++中创建一个json对象.我想添加一个时间戳,然后添加包含数据的数组.

这就是我的json String看起来像:

{
    "timestep": "2160.00",
    "vehicles": [
        {
            "id": "35092_35092_353",
            "x": "6.988270",
            "y": "50.872139",
            "angle": "-20.812787",
            "type": "passenger_P_14_1",
            "speed": "0.000000",
            "pos": "4.600000",
            "lane": "4.600000",
            "slope": "4.600000"
        },
        {
            "id": "35092_35092_353",
            "x": "6.988270",
            "y": "50.872139",
            "angle": "-20.812787",
            "type": "passenger_P_14_1",
            "speed": "0.000000",
            "pos": "4.600000",
            "lane": "4.600000",
            "slope": "4.600000"
        },
        {
            "id": "35092_35092_353",
            "x": "6.988270",
            "y": "50.872139",
            "angle": "-20.812787",
            "type": "passenger_P_14_1",
            "speed": "0.000000",
            "pos": "4.600000",
            "lane": "4.600000",
            "slope": "4.600000"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

我是C++的新手,我正在使用Casablanca(C++ REST SDK)包.所以我很难生成代码.我找不到任何有效的解决方案.我在维基上找到了这个

创建一个JSON对象:

json::value obj;
obj[L"key1"] = json::value::boolean(false); …
Run Code Online (Sandbox Code Playgroud)

c++ arrays json casablanca

12
推荐指数
4
解决办法
4万
查看次数

标签 统计

arrays ×1

c++ ×1

casablanca ×1

json ×1