小编Sha*_* C.的帖子

使用Json.net反序列化JSON对象数组

我试图使用一个API,使用以下示例结构为他们返回的json

[
   {
      "customer":{
         "first_name":"Test",
         "last_name":"Account",
         "email":"test1@example.com",
         "organization":"",
         "reference":null,
         "id":3545134,
         "created_at":"2013-08-06T15:51:15-04:00",
         "updated_at":"2013-08-06T15:51:15-04:00",
         "address":"",
         "address_2":"",
         "city":"",
         "state":"",
         "zip":"",
         "country":"",
         "phone":""
      }
   },
   {
      "customer":{
         "first_name":"Test",
         "last_name":"Account2",
         "email":"test2@example.com",
         "organization":"",
         "reference":null,
         "id":3570462,
         "created_at":"2013-08-12T11:54:58-04:00",
         "updated_at":"2013-08-12T11:54:58-04:00",
         "address":"",
         "address_2":"",
         "city":"",
         "state":"",
         "zip":"",
         "country":"",
         "phone":""
      }
   }
]
Run Code Online (Sandbox Code Playgroud)

JSON.net可以使用类似以下结构的东西

{
    "customer": {
        ["field1" : "value", etc...],
        ["field1" : "value", etc...],
    }
}
Run Code Online (Sandbox Code Playgroud)

但我无法弄清楚如何让它对提供的结构感到满意.

使用默认的JsonConvert.DeserializeObject(content)会生成正确的Customer数,但所有数据都为null.

在CustomerList(下面)执行某些操作会导致"无法反序列化当前JSON数组"异常

public class CustomerList
{
    public List<Customer> customer { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

思考?

c# json.net

110
推荐指数
2
解决办法
19万
查看次数

安装angularcli EACCES时,在npm中警告gyp?

尝试使用命令安装angular cli时

sudo npm install -g @angular/cli
Run Code Online (Sandbox Code Playgroud)

它似乎赶上了一个错误循环与下面的消息

gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp"
gyp verb tmpdir == cwd automatically will remove dev files after to save disk space
gyp verb command install [ '8.9.4' ]
gyp verb install input version string "8.9.4"
gyp verb install installing version: 8.9.4
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 8.9.4
gyp verb ensuring …
Run Code Online (Sandbox Code Playgroud)

node.js angular

9
推荐指数
0
解决办法
1268
查看次数

标签 统计

angular ×1

c# ×1

json.net ×1

node.js ×1