> For the complete documentation index, see [llms.txt](https://alexisvisco.gitbook.io/kcd/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alexisvisco.gitbook.io/kcd/input/nested-fields-and-path-system.md).

# Nested fields and path system

KCD works well with nested types and the path system solves almost all use cases.

```go
package main

import (
   "fmt"
   "net/http"

   "github.com/go-chi/chi"

   "github.com/alexisvisco/kcd"
)

func main() {
   r := chi.NewRouter()
   r.Post("/", kcd.Handler(YourHttpHandler, http.StatusOK))
   _ = http.ListenAndServe(":3000", r)
}

type NestedStruct struct {
   Name string `query:"name"`
}

type CustomInput struct {
   Nested NestedStruct `query:"nested"` // ?nested.name=kcd
   
   NestedStruct // ?name=kcd

   Anonymous struct{
      Key string `query:"key"` // ?key=kcd
   }

   AnonymousValue struct{
      Value string `query:"key"` // ?anonymous.key=kcd
      NestedStruct // ?anonymous.name=kcd
   } `query:"anonymous"`
}

func YourHttpHandler(in *CustomInput) (*CustomInput, error) {
   fmt.Printf("%+v", in)

   return in, nil
}

// Test it : curl -XPOST 'localhost:3000?nested.name=alexis&name=remi&key=antoine&anonymous.key=superman&anonymous.name=batman'
```

The path system only adds the parent to the path if the same corresponding tag is present.&#x20;

The path system works only with query, ctx, path, and header tags. Since JSON decoding is handled by the default unmarshaler.&#x20;
