Lars Melander
Lars Melander

Reputation: 529

What is the correct way of handling JSON RecordID?

I have a piece of JSON that printed to console looks like:

{ '@rid': RecordID { cluster: 45, position: 40 } }

Stringifying this returns:

{"@rid":"#45:40"}

However, I'd prefer if the RecordID was not converted to a string.

I can pick out the individual values by:

json["@rid"].cluster   // returns 45
json["@rid"].position  // returns 40

But handling the RecordID directly always returns an error. How can I avoid that?

Upvotes: 1

Views: 91

Answers (1)

Hethcox
Hethcox

Reputation: 108

This is half an answer but there's a parse method:

const RID = require('orientjs').RecordID;
RID.parse(result['@rid'])

Is returns a record, but not the string that would be, you know, useful.

Upvotes: 0

Related Questions