Skip to content

Failed to decode nested fields #18

Description

@bekverdyan

I'm trying to decode nested values from JSON like this:

{
  name: 'exo',
    code: '1212',
      nested: {
    name: 'lika',
      code: '020202',
        place: 'somewhere'
  },
  other1: 'oooo',
    other2: 8989
}

and got an error:

The value `undefined` is not of type `string`, but is of type `undefined`
when trying to decode the key `place` in `{"name":"exo","code":"1212","nested":{"name":"lika","code":"020202","place":"somewhere"},"other1":"oooo","other2":8989}

This is my decoder function:

const dataDecoder = record({
  name: field('nested', field('name', string)),
  place: field('nested', field('place', string))
});

How can I decode values from nested objects?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions