Neo4j.rb : as_json how to ignore root?

54 views Asked by At

For Active record its working fine

ActiveRecord::Base.include_root_in_json = false

User.first.as_json

=> { "id" => 1, "name" => "Konata Izumi", "age" => 16,
     "created_at" => "2006/08/01", "awesome" => true}

When I use it for Neo4j.rb active node

Person.first.as_json

=> {"person"=> {" first_name"=>"Kay", "last_name" => "Wood",
    "email" => "[email protected]" } }

This how I am going to send repsosne by API, I don't need this root element Any help??

1

There are 1 answers

0
Eric Duminil On BEST ANSWER

From the neo4j documentation :

include_root_in_json

When serializing ActiveNode and ActiveRel objects, should there be a root in the JSON of the model name.

Default: true

So you could just add

config.neo4j.include_root_in_json = false

in config/application.rb.