[英]Returned JSON in Orientdb Using Function
I tried to execute this code using functions at OrientDB Studio. 我尝试使用OrientDB Studio中的函数执行此代码。
commandResult = db.executeCommand('insert into user (facebookId,instagramId) values ("' + facebookId +'","'+ instagramId +'");
if( commandResult.length == 0){
response.send(200, "ok", "application/json","{\"success\":\"false\"}");
} else {
response.send(200, "ok", "application/json","{\"success\":\"true\", \"@rid\" : \"" + commandResult + "\"}");
} }
and then it returns like this {"success":"true", "@rid" : "user#11:15{facebookId:df,instagramId:sdf} v1"}
然后像这样返回
{"success":"true", "@rid" : "user#11:15{facebookId:df,instagramId:sdf} v1"}
My problem now is i want only to return only the rid value. 我现在的问题是我只想返回rid值。 But the problem is in my second key
"user#11:15{facebookId:df,instagramId:sdf} v1"
. 但是问题出在我的第二个键
"user#11:15{facebookId:df,instagramId:sdf} v1"
。 I don't know how am I going to parse it since the @rid
is in the outside of the curly brace. 我不知道该怎么解析,因为
@rid
位于花括号的外面。
Hope from your positive response. 希望您的积极回应。
Thanks. 谢谢。
You're concatenating strings. 您正在串联字符串。 Use the .toJSON() instead:
使用.toJSON()代替:
response.send(200, "ok", "application/json",
"{ \"success\":\"true\", \"@rid\" : \"" +
commandResult.toJSON() + "\"}");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.