> For the complete documentation index, see [llms.txt](https://docs.starcounter.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.starcounter.io/2.3.1/guides/typed-json/accepting-json-in-requests.md).

# Accepting JSON in Requests

## Introduction

Typed JSON objects can be used as a representation of the HTTP (or other REST protocol) request body payload. To accept a JSON object in a PUT message, simply declare a parameter with the type `Json`.

## Example

{% code title="PersonMsg.json" %}

```javascript
{
   "FirstName": "",
   "LastName": "",
   "Age": 0
}
```

{% endcode %}

{% code title="Program.cs" %}

```csharp
using Starcounter;

class Hello
{
   static void Main()
   {
      Handle.PUT("/hello/{?}", ( string name, PersonMsg message ) =>
      {
         return "Welcome " + name + " you are " + message.Age + " years old.";
      });         
   }
}
```

{% endcode %}

The parameter is not associated with the URI template, so the content of the body will be used to fill in the object.

Now you can call the above handler with a HTTP request, for example using `XMLHttpRequest` in a web browser or manually using cURL:

```
$ curl -X PUT -H "Content-Type: application/json"
-d "{FirstName:"Olle",LastName:"Svensson", Age:49}"
http://localhost:8080/hello/Olle

Welcome Olle you are 49 years old.
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.starcounter.io/2.3.1/guides/typed-json/accepting-json-in-requests.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
