OrientRecord - JSON Serialisation Issue
Closed this issue · 2 comments
Hi,
I am trying to execute this query using pyorient:
response = client.query("select @this.toJson('rid,version,fetchPlan:in__:-2 out__:-2') from Worker where userName = '" + userName + "'")
Im expecting 0 or 1 result, but the SQL itself returns JSON and can confirm it works in studio. When used as part of a microservice, I get the error below as the OrientRecord:
<pyorient.otypes.OrientRecord object at 0x7feb13272990> is not JSON serializable"
As the select statement returns JSON from the server, how can I use pyorient query for this?
Cheers
Kurt
I tried running your query in my version of pyorient and the result came back fine. How are you trying to parse the json?
The json should be in a variable called "this".
Try making that call like this:
res = client.command("SELECT @this.toJson('rid,version,fetchPlan:in_:-2 out_:-2') FROM Worker WHERE userName = '%s';" % userName)
obj = json.loads(res[0].this)