Does anyone have a working example of inserting / selecting JSON in OrientDB?

Selecting a query for JSON in OrientDB does not work. Can someone provide a working example demonstrating two things:

  • Inserting JSON data correctly

  • JSON data request

Thanks!

+7
source share
3 answers

1.Use "content" to implement JSON insertion.

For example -
insert into Person content {"name":"nawab","age":25}

To do this, you need to preset as 1. Create a vertex using

 create class Person extends V 

2. Then create the name and age property

create property Person.name string
create property Person.age integer

+4
source

Here you go! I tried to figure this out for a while and finally got it to work. :)

Run the following sql commands as shown:

 create class EXAMPLE /* The trick is: Do not 'CREATE' the property with any type */ insert into EXAMPLE (my_prop) values ({"name": "James", "age": 23}) insert into EXAMPLE (my_prop) values ({"name": "Harden", "age": 24}) /* Fetch the fields inside the JSON */ select my_prop.name from example select my_prop.age from example where my_prop.name like 'James' 

I read this example from a book: Getting Started with OrientDB Claudio Tesoriero

Hope this helps!

+3
source

This question continues in the OrientDB group here . Have you tried if everything works?

+1
source

All Articles