0

I use the Neo4j.Driver nuget package, and I want my result as a JSON object.

When I use The Neo4j Console, I can see the result in JSON format. And I can build a Cyper query which returns in it, But How Can I get in C#? Here is the Query:

 MATCH (p:Person) 
 WHERE p.PersonId = '12345'
RETURN p AS PersonData

It works well, but when I use this command in session.Run() the return value is a IStatementResult which is contains IRecord or list of IRecord.

I Can read all element from record like this:

string id = record["PersonId"];
string name = record["Name"];

But I want it in JSON :)

 string jsonData = MagicFunction_WhichReturn_WithJSON( record );

It must be possible, beacuse some post are write about it like this or this. Just a mechanism is not described.

I feel it must be very simple solution, Just I did not found it :(

György Gulyás
  • 1,290
  • 11
  • 37

1 Answers1

0

You could use a JSON serializer/deserializer library such as Newtosoft.Json, or the native System.Web.Script.Serialization.JavaScriptSerializer class, using it as

string jsonData = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(record)

or

string jsonData = Newtonsoft.Json.JsonConvert.SerializeObject(record)
Banned007
  • 15
  • 8