# Complex JSON deserialization

**URL:** <https://forum.crystal-lang.org/t/complex-json-deserialization/6095>\
**Category:** Help & Support\
**Created:** [October 17, 2023, 4:14am UTC](https://forum.crystal-lang.org/t/complex-json-deserialization/6095 "2023-10-17T04:14:48Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![hugopl](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/hugopl/32/970_2.png) [@hugopl](https://forum.crystal-lang.org/u/hugopl)\
**Post date:** [October 29, 2023, 3:39am UTC](https://forum.crystal-lang.org/t/complex-json-deserialization/6095/10 "2023-10-29T03:39:26Z")

</div>

> [@straight-shoota](#):
>
> Yes you can do the latter with custom converter for this particular, nested field.
> 
> ```auto
> @[JSON::Field(key: "complicated", converter: Thing::NestedArrayConverter)]
> property nested_array : Array(String)
>   
> module NestedArrayConverter
> def self.from_json(pull)
> pull.on_key!("object") do
> pull.on_key!("nested") do
> pull.on_key!("deeply") do
> return Array(String).new(pull)
> end
> end
> end
> end
> end
> 
> ```

This make me think that I wont be the only one that could find [my imcomplete proposal to stdlib](https://forum.crystal-lang.org/t/let-json-pullparser-on-key-work-with-nested-keys/6077) useful.

The above code would be

```auto
  @[JSON::Field(key: "complicated", converter: Thing::NestedArrayConverter)]
  property nested_array : Array(String)
  
  module NestedArrayConverter
    def self.from_json(pull)
      pull.on_key!("object", "nested", "deeply") do
        return Array(String).new(pull)
      end
    end
  end

```

---

_[View the full topic](https://forum.crystal-lang.org/t/complex-json-deserialization/6095)._
