从 Neo4J 2.2.2 反序列化 Json
Deserialize Json from Neo4J 2.2.2
我正在使用 Neo4J 版本 2.2.2。
当 Neo4jClient 尝试反序列化以下 json(模式投影)时,我们收到以下消息:
Neo4j returned a valid response, however Neo4jClient was unable to deserialize into the object structure you supplied.
First, try and review the exception below to work out what broke.
Include the full text of this exception, including this message, the stack trace, and all of the inner exception details.
Include the full type definition of VB$AnonymousType_0`2[[Person, App_Code.tynn6afz, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null],[Movie, App_Code.tynn6afz, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]].
包含此原始 JSON,并将所有敏感值替换为非敏感值:
{
"columns": [
"person",
"movie"
],
"data": [
[
{
"outgoing_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/out",
"labels": "http://sjkdv37:7474/db/data/node/324/labels",
"data": {
"born": 1956,
"name": "Tom Hanks"
},
"all_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/all/{-list|&|types}",
"traverse": "http://sjkdv37:7474/db/data/node/324/traverse/{returnType}",
"self": "http://sjkdv37:7474/db/data/node/324",
"property": "http://sjkdv37:7474/db/data/node/324/properties/{key}",
"properties": "http://sjkdv37:7474/db/data/node/324/properties",
"outgoing_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/out/{-list|&|types}",
"incoming_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/in",
"extensions": {},
"create_relationship": "http://sjkdv37:7474/db/data/node/324/relationships",
"paged_traverse": "http://sjkdv37:7474/db/data/node/324/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/all",
"incoming_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/in/{-list|&|types}",
"metadata": {
"id": 324,
"labels": [
"Person"
]
}
},
{
"outgoing_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/out",
"labels": "http://sjkdv37:7474/db/data/node/364/labels",
"data": {
"released": 2006,
"title": "The Da Vinci Code",
"tagline": "Break The Codes"
},
"all_typed_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/all/{-list|&|types}",
"traverse": "http://sjkdv37:7474/db/data/node/364/traverse/{returnType}",
"self": "http://sjkdv37:7474/db/data/node/364",
"property": "http://sjkdv37:7474/db/data/node/364/properties/{key}",
"properties": "http://sjkdv37:7474/db/data/node/364/properties",
"outgoing_typed_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/out/{-list|&|types}",
"incoming_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/in",
"extensions": {},
"create_relationship": "http://sjkdv37:7474/db/data/node/364/relationships",
"paged_traverse": "http://sjkdv37:7474/db/data/node/364/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/all",
"incoming_typed_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/in/{-list|&|types}",
"metadata": {
"id": 364,
"labels": [
"Movie"
]
}
}
],
[
{
"outgoing_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/out",
"labels": "http://sjkdv37:7474/db/data/node/324/labels",
"data": {
"born": 1956,
"name": "Tom Hanks"
},
"all_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/all/{-list|&|types}",
"traverse": "http://sjkdv37:7474/db/data/node/324/traverse/{returnType}",
"self": "http://sjkdv37:7474/db/data/node/324",
"property": "http://sjkdv37:7474/db/data/node/324/properties/{key}",
"properties": "http://sjkdv37:7474/db/data/node/324/properties",
"outgoing_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/out/{-list|&|types}",
"incoming_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/in",
"extensions": {},
"create_relationship": "http://sjkdv37:7474/db/data/node/324/relationships",
"paged_traverse": "http://sjkdv37:7474/db/data/node/324/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/all",
"incoming_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/in/{-list|&|types}",
"metadata": {
"id": 324,
"labels": [
"Person"
]
}
},
{
"outgoing_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/out",
"labels": "http://sjkdv37:7474/db/data/node/414/labels",
"data": {
"released": 2004,
"title": "The Polar Express",
"tagline": "This Holiday Season… Believe"
},
"all_typed_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/all/{-list|&|types}",
"traverse": "http://sjkdv37:7474/db/data/node/414/traverse/{returnType}",
"self": "http://sjkdv37:7474/db/data/node/414",
"property": "http://sjkdv37:7474/db/data/node/414/properties/{key}",
"properties": "http://sjkdv37:7474/db/data/node/414/properties",
"outgoing_typed_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/out/{-list|&|types}",
"incoming_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/in",
"extensions": {},
"create_relationship": "http://sjkdv37:7474/db/data/node/414/relationships",
"paged_traverse": "http://sjkdv37:7474/db/data/node/414/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/all",
"incoming_typed_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/in/{-list|&|types}",
"metadata": {
"id": 414,
"labels": [
"Movie"
]
}
}
]
]
}
编辑
我包含了 VB 代码,但我认为此错误是由 Neo4jClient 生成的。
可能错误出在 CypherJsonDeserializer.cs
处的 ParseInProjectionMode 函数周围
Dim user As String = "neo4j"
Dim pwd As String = "password"
Dim server As String = "localhost:7474"
Dim link As String = "http://{0}:{1}@{2}/db/data"
Dim url As New Uri(String.Format(link, user, pwd, server))
Dim client As New GraphClient(url)
client.Connect()
Dim query = client.Cypher _
.Match("(p:Person {name: ""Tom Hanks""})-[:ACTED_IN]->(m:Movie)") _
.Return(Function(p, m) New With {
.person = p.As(Of Person)(), _
.movie = m.As(Of Movie)()
})
'Here the client threw an Exception
For Each item In query.Results
Dim temp As String = String.Format("{0} - {1}<br>", item.movie.title, item.movie.released)
divOut.InnerHtml += temp
Next
此外,我还创建了论文类。
Public Class Movie
Public Property title As String
Public Property released As Integer
Public Property tagline As String
End Class
Public Class Person
Public Property name As String
Public Property born As Integer
End Class
错误源于您正在创建的匿名类型,现在,我不假装知道为什么,并且不花一些时间挖掘 Neo4jClient
代码库 - 很难确切地找出。
你可以通过使用具体的方法来解决这个问题 类 这个例子可以工作并将数据输出到屏幕上(我想指出,我是 no vb 编码员,请原谅愚蠢的错误):
Module Module1
Private Class Together
Public Property Person As Person
Public Property Movie As Movie
End Class
Sub Main()
Dim user = "neo4j"
Dim pwd = "password"
Dim server = "localhost:7474"
Dim link = "http://{0}:{1}@{2}/db/data"
Dim url As New Uri(String.Format(link, user, pwd, server))
Dim client As New GraphClient(url)
client.Connect()
Dim query = New CypherFluentQuery(client) _
.Match("(p:Person {name: ""Tom Hanks""})-[:ACTED_IN]->(m:Movie)") _
.Return(Function(p, m) New Together With {
.Person = p.As(Of Person)(), _
.Movie = m.As(Of Movie)()
})
Dim results = query.Results.ToList()
For Each item In results
Dim temp As String = String.Format("{0} - {1}<br>", item.Movie.title, item.Movie.released)
Console.WriteLine(temp)
Next
Console.ReadLine()
End Sub
End Module
根据您的 类 定义,因为您已经拥有它们。
您可以尝试在 Neo4jClient
代码库中修复此问题并发出拉取请求(这会很好),如果您真的需要它,目前您可能想要获得编码并使用您自己的编译版本而不是 nuget,因为积极的开发似乎暂停了一小段时间。
PS。它 是 vb 特定的,C# 对此非常满意匿名类型,因此可能在代码库中无法识别的 VB 中以某种方式处理匿名类型。
我正在使用 Neo4J 版本 2.2.2。
当 Neo4jClient 尝试反序列化以下 json(模式投影)时,我们收到以下消息:
Neo4j returned a valid response, however Neo4jClient was unable to deserialize into the object structure you supplied. First, try and review the exception below to work out what broke. Include the full text of this exception, including this message, the stack trace, and all of the inner exception details. Include the full type definition of VB$AnonymousType_0`2[[Person, App_Code.tynn6afz, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null],[Movie, App_Code.tynn6afz, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]].
包含此原始 JSON,并将所有敏感值替换为非敏感值:
{
"columns": [
"person",
"movie"
],
"data": [
[
{
"outgoing_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/out",
"labels": "http://sjkdv37:7474/db/data/node/324/labels",
"data": {
"born": 1956,
"name": "Tom Hanks"
},
"all_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/all/{-list|&|types}",
"traverse": "http://sjkdv37:7474/db/data/node/324/traverse/{returnType}",
"self": "http://sjkdv37:7474/db/data/node/324",
"property": "http://sjkdv37:7474/db/data/node/324/properties/{key}",
"properties": "http://sjkdv37:7474/db/data/node/324/properties",
"outgoing_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/out/{-list|&|types}",
"incoming_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/in",
"extensions": {},
"create_relationship": "http://sjkdv37:7474/db/data/node/324/relationships",
"paged_traverse": "http://sjkdv37:7474/db/data/node/324/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/all",
"incoming_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/in/{-list|&|types}",
"metadata": {
"id": 324,
"labels": [
"Person"
]
}
},
{
"outgoing_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/out",
"labels": "http://sjkdv37:7474/db/data/node/364/labels",
"data": {
"released": 2006,
"title": "The Da Vinci Code",
"tagline": "Break The Codes"
},
"all_typed_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/all/{-list|&|types}",
"traverse": "http://sjkdv37:7474/db/data/node/364/traverse/{returnType}",
"self": "http://sjkdv37:7474/db/data/node/364",
"property": "http://sjkdv37:7474/db/data/node/364/properties/{key}",
"properties": "http://sjkdv37:7474/db/data/node/364/properties",
"outgoing_typed_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/out/{-list|&|types}",
"incoming_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/in",
"extensions": {},
"create_relationship": "http://sjkdv37:7474/db/data/node/364/relationships",
"paged_traverse": "http://sjkdv37:7474/db/data/node/364/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/all",
"incoming_typed_relationships": "http://sjkdv37:7474/db/data/node/364/relationships/in/{-list|&|types}",
"metadata": {
"id": 364,
"labels": [
"Movie"
]
}
}
],
[
{
"outgoing_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/out",
"labels": "http://sjkdv37:7474/db/data/node/324/labels",
"data": {
"born": 1956,
"name": "Tom Hanks"
},
"all_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/all/{-list|&|types}",
"traverse": "http://sjkdv37:7474/db/data/node/324/traverse/{returnType}",
"self": "http://sjkdv37:7474/db/data/node/324",
"property": "http://sjkdv37:7474/db/data/node/324/properties/{key}",
"properties": "http://sjkdv37:7474/db/data/node/324/properties",
"outgoing_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/out/{-list|&|types}",
"incoming_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/in",
"extensions": {},
"create_relationship": "http://sjkdv37:7474/db/data/node/324/relationships",
"paged_traverse": "http://sjkdv37:7474/db/data/node/324/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/all",
"incoming_typed_relationships": "http://sjkdv37:7474/db/data/node/324/relationships/in/{-list|&|types}",
"metadata": {
"id": 324,
"labels": [
"Person"
]
}
},
{
"outgoing_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/out",
"labels": "http://sjkdv37:7474/db/data/node/414/labels",
"data": {
"released": 2004,
"title": "The Polar Express",
"tagline": "This Holiday Season… Believe"
},
"all_typed_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/all/{-list|&|types}",
"traverse": "http://sjkdv37:7474/db/data/node/414/traverse/{returnType}",
"self": "http://sjkdv37:7474/db/data/node/414",
"property": "http://sjkdv37:7474/db/data/node/414/properties/{key}",
"properties": "http://sjkdv37:7474/db/data/node/414/properties",
"outgoing_typed_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/out/{-list|&|types}",
"incoming_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/in",
"extensions": {},
"create_relationship": "http://sjkdv37:7474/db/data/node/414/relationships",
"paged_traverse": "http://sjkdv37:7474/db/data/node/414/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/all",
"incoming_typed_relationships": "http://sjkdv37:7474/db/data/node/414/relationships/in/{-list|&|types}",
"metadata": {
"id": 414,
"labels": [
"Movie"
]
}
}
]
]
}
编辑
我包含了 VB 代码,但我认为此错误是由 Neo4jClient 生成的。
可能错误出在 CypherJsonDeserializer.cs
处的 ParseInProjectionMode 函数周围Dim user As String = "neo4j"
Dim pwd As String = "password"
Dim server As String = "localhost:7474"
Dim link As String = "http://{0}:{1}@{2}/db/data"
Dim url As New Uri(String.Format(link, user, pwd, server))
Dim client As New GraphClient(url)
client.Connect()
Dim query = client.Cypher _
.Match("(p:Person {name: ""Tom Hanks""})-[:ACTED_IN]->(m:Movie)") _
.Return(Function(p, m) New With {
.person = p.As(Of Person)(), _
.movie = m.As(Of Movie)()
})
'Here the client threw an Exception
For Each item In query.Results
Dim temp As String = String.Format("{0} - {1}<br>", item.movie.title, item.movie.released)
divOut.InnerHtml += temp
Next
此外,我还创建了论文类。
Public Class Movie
Public Property title As String
Public Property released As Integer
Public Property tagline As String
End Class
Public Class Person
Public Property name As String
Public Property born As Integer
End Class
错误源于您正在创建的匿名类型,现在,我不假装知道为什么,并且不花一些时间挖掘 Neo4jClient
代码库 - 很难确切地找出。
你可以通过使用具体的方法来解决这个问题 类 这个例子可以工作并将数据输出到屏幕上(我想指出,我是 no vb 编码员,请原谅愚蠢的错误):
Module Module1
Private Class Together
Public Property Person As Person
Public Property Movie As Movie
End Class
Sub Main()
Dim user = "neo4j"
Dim pwd = "password"
Dim server = "localhost:7474"
Dim link = "http://{0}:{1}@{2}/db/data"
Dim url As New Uri(String.Format(link, user, pwd, server))
Dim client As New GraphClient(url)
client.Connect()
Dim query = New CypherFluentQuery(client) _
.Match("(p:Person {name: ""Tom Hanks""})-[:ACTED_IN]->(m:Movie)") _
.Return(Function(p, m) New Together With {
.Person = p.As(Of Person)(), _
.Movie = m.As(Of Movie)()
})
Dim results = query.Results.ToList()
For Each item In results
Dim temp As String = String.Format("{0} - {1}<br>", item.Movie.title, item.Movie.released)
Console.WriteLine(temp)
Next
Console.ReadLine()
End Sub
End Module
根据您的 类 定义,因为您已经拥有它们。
您可以尝试在 Neo4jClient
代码库中修复此问题并发出拉取请求(这会很好),如果您真的需要它,目前您可能想要获得编码并使用您自己的编译版本而不是 nuget,因为积极的开发似乎暂停了一小段时间。
PS。它 是 vb 特定的,C# 对此非常满意匿名类型,因此可能在代码库中无法识别的 VB 中以某种方式处理匿名类型。