簡體   English   中英

如何將json內部對象放入另一種相同類型的json對象中

[英]How to put json inner object into another same type of json object

我有一個JSON對象,如下所示。

var obj = {
    "_id": "mand-configurations",
    "server-host": "0.0.0.0",
    "server-port": [1890, 1770, 2070],
    "server-rest-api-timeout-in-millis": 3020,
    "server-started": "server started successfuly",
    "stopped-snmp": "server shutdown",
    "connection-failed": "connection to pgw-server failed",
    "request-time-out": "pgw-server request time out",
    "notify-connection-failed-snmp": "connection to notification-server failed",
    "subscription": {
        "control-data": [
            "app",
            "sp"
        ],
        "callback-url": "http://core.sdp:19980/notify",
        "post-notification": true
    },
    "charging-start-time": "01:00",
    "charging-schedulers": [
        {
            "scheduler-name": "fifteen",
            "charging-scheduler-type": "fifteen-days",
            "initial-delay": 10000,
            "batch-execution": 10000,
            "batch-execution-size": 100,
            "charging-schedules": [
                {
                    "charging-model-name": "fixed-fifteen"
                }
            ]
        }
    ]
}

然后我得到一個副本並更改值。

var cpyObj = obj;

cpyObj["charging-schedulers"][0]["scheduler-name"] = "some value"

那么我需要使用新的cpyObj的值更新以前的obj。 我該怎么做。

在“ cpyObj”中進行任何更改也將更改“ Obj”,因為不執行復制。 是的,我相信您不需要做任何事情。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM