c#Json添加新值

时间:2016-07-18 17:25:02

标签: c# json duplicates append add

我需要一个C#Json添加新值。例如:

默认的json:http://pastebin.com/RTG6MD4Z

您知道这一行: "authenticationDatabase": { "UUID": { "displayName": "name", "accessToken": "accessToken", "userid": "random", "uuid": "uuid", "username": "**Hidden**" } },

验证身份验证数据库:{添加新值}

"authenticationDatabase": {
"UUID": {
  "displayName": "name",
  "accessToken": "accessToken",
  "userid": "random",
  "uuid": "uuid",
  "username": "**Hidden**"
},
"UUID": { // And the uuid not "UUID" random characters. (The new value)
   "displayName": "name",
   "accessToken": "accessToken",
   "userid": "random",
   "uuid": "uuid",
   "username": "**Hidden**"
},
"UUID": { // And the uuid not "UUID" random characters. (The new value)
   "displayName": "name",
   "accessToken": "accessToken",
   "userid": "random",
   "uuid": "uuid",
   "username": "**Hidden**"
}   

},`

1 个答案:

答案 0 :(得分:0)

您需要决定要做什么:

"UUID": [{
  "displayName": "name",
  "accessToken": "accessToken",
  "userid": "random",
  "uuid": "uuid",
  "username": "**Hidden**"
},
{ // And the uuid not "UUID" random characters. (The new value)
   "displayName": "name",
   "accessToken": "accessToken",
   "userid": "random",
   "uuid": "uuid",
   "username": "**Hidden**"
},
{ // And the uuid not "UUID" random characters. (The new value)
   "displayName": "name",
   "accessToken": "accessToken",
   "userid": "random",
   "uuid": "uuid",
   "username": "**Hidden**"
}]

也就是说,使用对象数组,或者确定不再使用JSON并编写自己的解析器和生成器。但是,如果您要与其他人来回传递此信息,则需要重新协商交换格式。