# is nested json structure supported for activerecord - postgresql?

**URL:** <https://discuss.rubyonrails.org/t/is-nested-json-structure-supported-for-activerecord-postgresql/68504>\
**Category:** rubyonrails-talk\
**Created:** [February 7, 2014, 12:38pm UTC](https://discuss.rubyonrails.org/t/is-nested-json-structure-supported-for-activerecord-postgresql/68504 "2014-02-07T12:38:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jae\_Lee](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@Jae\_Lee](https://discuss.rubyonrails.org/u/Jae_Lee)\
**Post date:** [February 7, 2014, 12:38pm UTC](https://discuss.rubyonrails.org/t/is-nested-json-structure-supported-for-activerecord-postgresql/68504/1 "2014-02-07T12:38:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jae\_Lee](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@Jae\_Lee](https://discuss.rubyonrails.org/u/Jae_Lee)\
**Post date:** [February 7, 2014, 1:45pm UTC](https://discuss.rubyonrails.org/t/is-nested-json-structure-supported-for-activerecord-postgresql/68504/2 "2014-02-07T13:45:23Z")

</div>

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

J
