In what way can I get fields within a JSON that is stored as a OrientDB Class field?
For example, I have a class FILE having a field named 'data'.
orientdb {db=baasbox}> select data from FILE
----+----------------------
# | data
----+----------------------
0 | {"email":"[email protected]"}
----+----------------------
The field 'data' is a JSON and I want to get the "email" field: using something like this:
orientdb {db=baasbox}> select data.email from FILE
----+----------------------
# | data.email
----+----------------------
0 | [email protected]
----+----------------------
This above sql doesn't work and gives this error: SEVE Error on reading rid with value '[{"email":"[email protected]"}]' [OSQLMethodField]
I already tried giving data.email
, data[email]
, data['email']
in the projection, but in vain.
Any help is appreciated.
I believe you defined data field as String when it should be Embedded. Try the following.
create class File
create property File.data EMBEDDED
insert into File set data = {"email":"[email protected]"}
select data.email from File
UPDATE:
For OrientDB versions prior to 2.0:
create class File
create property File.data EMBEDDED
insert into File set data = {"@type":"d", "email":"[email protected]"}
select data.email from File