Jbuilder を使用して、次の JSON オブジェクトをエンコードします。どうやってするの?
"should" : [
{
"term" : { "tag" : "wow" }
},
{
"term" : { "tag" : "elasticsearch" }
}
]
Jbuilder を使用して、次の JSON オブジェクトをエンコードします。どうやってするの?
"should" : [
{
"term" : { "tag" : "wow" }
},
{
"term" : { "tag" : "elasticsearch" }
}
]
子供を試してみてください!メソッド、例えば
output = Jbuilder.encode do |json|
json.should do
json.child! do
json.term { json.tag "wow" }
end
json.child! do
json.term { json.tag "elasticsearch" }
end
end
end
puts output
どちらが出力されますか:
{"should":[{"term":{"tag":"wow"}},{"term":{"tag":"elasticsearch"}}]}