Skip to content

I want to return a key in the object, how to do it? #199

@vxhly

Description

@vxhly

json1

{
"statisticsOption": [
          {
            "key": "date",
            "prop": "date",
            "name": "日期",
            "show": true,
            "description": "日期"
          },
          {
            "key": "failedSubscriptionUser",
            "prop": "failedSubscriptionUser",
            "name": "当日失败订阅用户数",
            "show": true,
            "description": "不重复的用户数"
          },
          {
            "key": "successSubscription",
            "prop": "successSubscription",
            "name": "当日成功订阅",
            "show": true,
            "description": "不含退款"
          }
]
}

json2

{
"statisticsOption": [
          {
            "key": "date",
            "prop": "date",
            "name": "日期1",
            "show": true,
            "description": "日期1"
          },
          {
            "key": "failedSubscriptionUser",
            "prop": "failedSubscriptionUser",
            "name": "当日失败订阅用1户数",
            "show": true,
            "description": "不重复的1用户数"
          },
          {
            "key": "successSubscription",
            "prop": "successSubscription",
            "name": "当日成功1订阅",
            "show": true,
            "description": "不含1退款"
          }
]
}

Each object in the array has a unique value: key

let diffpatcher = jsondiffpatch.create({
  objectHash: (obj) => {
    return obj.key
   }
 })
console.log(diffpatcher .diff(json1, json2))

I want to return the only key value followed.
However, the key value has not actually been modified.
My data can not be changed to an object.
What should I do?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions