C或Java中的Neo4J密码:从“;返回JSON输出;调用db.schema.nodeTypeProperties()”;?
从Neo4J Broswer中调用C或Java中的Neo4J密码:从“;返回JSON输出;调用db.schema.nodeTypeProperties()”;?,java,c#,json,neo4j,cypher,Java,C#,Json,Neo4j,Cypher,从Neo4J Broswer中调用db.schema.nodeTypeProperties()时,代码端选项卡会在响应下拉列表中返回完整的JSON模式。是否可以使用Neo4J.Driver在C#或Java中检索这个JSON结果?我想将JSON文本反序列化为C#类 我已经研究了Neo4J.DriverIDriver、IAsyncSession和IResultCursor调用,但找不到检索JSON数据集的方法。我能够通过使用apoc.export.JSON.all在整个数据库的JSON数据集中进行
db.schema.nodeTypeProperties()
时,代码端选项卡会在响应下拉列表中返回完整的JSON模式。是否可以使用Neo4J.Driver在C#或Java中检索这个JSON结果?我想将JSON文本反序列化为C#类
我已经研究了Neo4J.Driver
IDriver
、IAsyncSession
和IResultCursor
调用,但找不到检索JSON数据集的方法。我能够通过使用apoc.export.JSON.all
在整个数据库的JSON数据集中进行流式处理来获得我想要的内容。我利用了当时的例子。我为我的问题被误导而道歉db.schema.nodeTypeProperties()
无法满足我的实际需要
using Newtonsoft.Json.Linq;
public async void TestNeo4j()
{
// Set up the graph database driver and connect the session to the Neo4J database.
IDriver driver = GraphDatabase.Driver(Neo4JBoltURI, AuthTokens.Basic(Neo4JUser, Neo4JPassword));
IAsyncSession session = driver.AsyncSession();
IResultCursor cursor;
try
{
// Bring the JSON text in as a stream
string query = "CALL apoc.export.json.all(null,{stream:true,useTypes:true}) " +
"YIELD file, nodes, relationships, properties, data " +
"RETURN file, nodes, relationships, properties, data";
cursor = await session.RunAsync(query);
string sJsonData = await cursor.SingleAsync(record => record["data"].As<string>());
//Debug.Log(sJsonData);
//// Save the JSON to a file.
//string path = @"C:\Users\Public\Documents\Neo4JExportAll.json";
//if (File.Exists(path)) File.Delete(path);
//File.WriteAllText(path, sJsonData);
// Each line is a separate JSON statement describing a node or a relationship
// Iterate all statements
using (StringReader reader = new StringReader(sJsonData))
{
string line = string.Empty;
do
{
line = reader.ReadLine();
if (line != null)
{
// Deserialize the JSON line into JObject jo.
JObject jo = JObject.Parse(line);
// Dig into the JObject to get the data from the stream.
}
} while (line != null);
}
}
finally
{
await session.CloseAsync();
}
}
使用Newtonsoft.Json.Linq;
公共异步void TestNeo4j()
{
//设置图形数据库驱动程序并将会话连接到Neo4J数据库。
IDriver driver=GraphDatabase.driver(Neo4JBoltURI,AuthTokens.Basic(Neo4JUser,Neo4JPassword));
IAsyncSession会话=driver.AsyncSession();
iResult光标;
尝试
{
//将JSON文本作为流引入
string query=“CALL apoc.export.json.all(null,{stream:true,useTypes:true})”+
生成文件、节点、关系、属性、数据+
“返回文件、节点、关系、属性、数据”;
cursor=wait session.RunAsync(查询);
字符串sJsonData=await cursor.SingleAsync(record=>record[“data”].As());
//Log(sJsonData);
////将JSON保存到文件中。
//字符串路径=@“C:\Users\Public\Documents\Neo4JExportAll.json”;
//如果(File.Exists(path))File.Delete(path);
//File.writealText(路径,sJsonData);
//每一行都是一个单独的JSON语句,描述一个节点或一个关系
//迭代所有语句
使用(StringReader=新StringReader(sJsonData))
{
string line=string.Empty;
做
{
line=reader.ReadLine();
如果(行!=null)
{
//将JSON行反序列化为JObject jo。
JObject jo=JObject.Parse(行);
//深入JObject以从流中获取数据。
}
}while(line!=null);
}
}
最后
{
等待会话。CloseAsync();
}
}
通过使用apoc.export.json.all在整个数据库的json数据集中进行流式传输,我能够得到我想要的东西。我利用了当时的例子。我为我的问题被误导而道歉db.schema.nodeTypeProperties()
无法满足我的实际需要
using Newtonsoft.Json.Linq;
public async void TestNeo4j()
{
// Set up the graph database driver and connect the session to the Neo4J database.
IDriver driver = GraphDatabase.Driver(Neo4JBoltURI, AuthTokens.Basic(Neo4JUser, Neo4JPassword));
IAsyncSession session = driver.AsyncSession();
IResultCursor cursor;
try
{
// Bring the JSON text in as a stream
string query = "CALL apoc.export.json.all(null,{stream:true,useTypes:true}) " +
"YIELD file, nodes, relationships, properties, data " +
"RETURN file, nodes, relationships, properties, data";
cursor = await session.RunAsync(query);
string sJsonData = await cursor.SingleAsync(record => record["data"].As<string>());
//Debug.Log(sJsonData);
//// Save the JSON to a file.
//string path = @"C:\Users\Public\Documents\Neo4JExportAll.json";
//if (File.Exists(path)) File.Delete(path);
//File.WriteAllText(path, sJsonData);
// Each line is a separate JSON statement describing a node or a relationship
// Iterate all statements
using (StringReader reader = new StringReader(sJsonData))
{
string line = string.Empty;
do
{
line = reader.ReadLine();
if (line != null)
{
// Deserialize the JSON line into JObject jo.
JObject jo = JObject.Parse(line);
// Dig into the JObject to get the data from the stream.
}
} while (line != null);
}
}
finally
{
await session.CloseAsync();
}
}
使用Newtonsoft.Json.Linq;
公共异步void TestNeo4j()
{
//设置图形数据库驱动程序并将会话连接到Neo4J数据库。
IDriver driver=GraphDatabase.driver(Neo4JBoltURI,AuthTokens.Basic(Neo4JUser,Neo4JPassword));
IAsyncSession会话=driver.AsyncSession();
iResult光标;
尝试
{
//将JSON文本作为流引入
string query=“CALL apoc.export.json.all(null,{stream:true,useTypes:true})”+
生成文件、节点、关系、属性、数据+
“返回文件、节点、关系、属性、数据”;
cursor=wait session.RunAsync(查询);
字符串sJsonData=await cursor.SingleAsync(record=>record[“data”].As());
//Log(sJsonData);
////将JSON保存到文件中。
//字符串路径=@“C:\Users\Public\Documents\Neo4JExportAll.json”;
//如果(File.Exists(path))File.Delete(path);
//File.writealText(路径,sJsonData);
//每一行都是一个单独的JSON语句,描述一个节点或一个关系
//迭代所有语句
使用(StringReader=新StringReader(sJsonData))
{
string line=string.Empty;
做
{
line=reader.ReadLine();
如果(行!=null)
{
//将JSON行反序列化为JObject jo。
JObject jo=JObject.Parse(行);
//深入JObject以从流中获取数据。
}
}while(line!=null);
}
}
最后
{
等待会话。CloseAsync();
}
}