Is nested json structure supported for activerecord - postgresql?

Hi all,

I’m using rails 4.1.0.beta 1 and postgresql 9.3.1 and its native support
for json column. so no special serializer or no special storage thing
with
active record, just plain :json type in active record migration.

in my active record model, I’ve got two json fields.

input: {“first_name”=>“firstName”, “last_name”=>“lastName”,
“postcode”=>“postcode”}
output: {“customer_detail”=>{“first_name”=>“firstName”,
“last_name”=>“lastName”, “postcode”=>“postcode”}}

model.input
=> {“first_name”=>“firstName”, “last_name”=>“lastName”,
“postcode”=>“postcode”}

model[:input]
=> {“first_name”=>“firstName”, “last_name”=>“lastName”,
“postcode”=>“postcode”}

model.input_before_type_cast
=> “{“first_name”:“firstName”, “last_name”:“lastName”,
“postcode”:“postcode”}”

model.output
=> nil

model[:output]
=> {“customer_detail”=>{“first_name”=>“firstName”,
“last_name”=>“lastName”,
“postcode”=>“postcode”}}

model.output_before_type_cast
=>
“{“customer_detail”:{“first_name”:“firstName”,“last_name”:“lastName”,“postcode”:“postcode”}}”

could someone explain why this is happening? I’m confused why this is
happening…

thanks!
J

ah don’t worry I’ve realised it was my own error…

J

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs