3

我开始测试 OrientDB。我从演示数据库中得到以下 JSON 响应:

{
    "schema":{
        "name":"OUser",
        "properties":{
            "roles":{
                "name":"roles",
                "linkedClass":"ORole",
                "type":"LINKSET",
                "mandatory":false,
                "notNull":true,
                "min":null,
                "max":null
            },
            "name":{
                "name":"name",
                "type":"STRING",
                "mandatory":true,
                "notNull":false,
                "min":null,
                "max":null
            },
            "password":{
                "name":"password",
                "type":"STRING",
                "mandatory":true,
                "notNull":false,
                "min":null,
                "max":null
            }
        }
    },
    "result":[
        {
            "@type":"d",
            "@rid":"#4:0",
            "@version":0,
            "@class":"OUser",
            "name":"admin",
            "password":"{SHA-256}8C6976E5B5410415BDE908BD4DEE15DFB167A9C873FC4BB8A81F6F2AB448A918",
            "status":"ACTIVE",
            "roles":[
                "#3:0"
            ]
        },
        {
            "@type":"d",
            "@rid":"#4:1",
            "@version":0,
            "@class":"OUser",
            "name":"reader",
            "password":"{SHA-256}3D0941964AA3EBDCB00CCEF58B1BB399F9F898465E9886D5AEC7F31090A0FB30",
            "status":"ACTIVE",
            "roles":[
                "#3:1"
            ]
        },
        {
            "@type":"d",
            "@rid":"#4:2",
            "@version":0,
            "@class":"OUser",
            "name":"writer",
            "password":"{SHA-256}B93006774CBDD4B299389A03AC3D88C3A76B460D538795BC12718011A909FBA5",
            "status":"ACTIVE",
            "roles":[
                "#3:2"
            ]
        }
    ]
}

如何从中获得 OUser 对象列表?使用 JSON.Net、JavaScriptSerializer 或其他什么?

4

3 回答 3

1

在http://www.json.org/上有许多 c# 的 json 解析器 。看起来 fastJSON 应该很快。

于 2011-11-17T09:25:47.923 回答
0

登录后对 OUser 类执行查询:

select from ouser

通过 HTTP 协议将是针对此地址的 GET 请求:

http://localhost:2480/query/demo/sql/select%20from%20ouser

{  
  "result": [{
    "@type": "d", "@rid": "#4:0", "@version": 0, "@class": "OUser", 
    "name": "admin", 
    "password": "{SHA-256}8C6976E5B5410415BDE908BD4DEE15DFB167A9C873FC4BB8A81F6F2AB448A918", 
    "status": "ACTIVE", 
    "roles": ["#3:0"]
  }, {
    "@type": "d", "@rid": "#4:1", "@version": 2, "@class": "OUser", 
    "name": "reader", 
    "password": "{SHA-256}3D0941964AA3EBDCB00CCEF58B1BB399F9F898465E9886D5AEC7F31090A0FB30", 
    "status": "ACTIVE", 
    "roles": ["#3:1"]
  }, {
    "@type": "d", "@rid": "#4:2", "@version": 0, "@class": "OUser", 
    "name": "writer", 
    "password": "{SHA-256}B93006774CBDD4B299389A03AC3D88C3A76B460D538795BC12718011A909FBA5", 
    "status": "ACTIVE", 
    "roles": ["#3:2"]
  }

] }

于 2011-11-17T16:35:50.430 回答
0

这看起来像一个使用 json.NET 反序列化的简单结构

于 2011-11-17T16:53:31.080 回答