Neo4j.rb : as_json 如何忽略 root?

Neo4j.rb : as_json how to ignore root?

对于 Active Record,它工作正常

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}

当我将它用于Neo4j.rb活动节点时

Person.first.as_json

=> {"person"=> {" first_name"=>"Kay", "last_name" => "Wood",
    "email" => "wood.kay@kozey.co" } }

这是我将如何通过 API 发送 repsosne,我不需要这个根元素任何帮助??

来自 neo4j 文档:

include_root_in_json

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

Default: true

所以你可以添加

config.neo4j.include_root_in_json = false

config/application.rb.