简体   繁体   中英

Returned JSON in Orientdb Using Function

I tried to execute this code using functions at 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"}

My problem now is i want only to return only the rid value. But the problem is in my second key "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.

Hope from your positive response.

Thanks.

You're concatenating strings. Use the .toJSON() instead:

response.send(200, "ok", "application/json",
"{ \"success\":\"true\", \"@rid\" : \"" + 
 commandResult.toJSON()  + "\"}");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM