# JSON Response Example

> View how g.res.contentType = JSON structures your APIs’ JSON response in API Maker with status codes, data, errors, and warnings.

Source: https://docs.apimaker.dev/v1/examples/res/contentType/JSON.html

## JSON

**Content type JSON**

```typescript
g.res.contentType = T.EContentType.JSON;
g.res.errors = [{ code: 401, message: "This is error" }];
g.res.statusCode = 555;
return "World";
```

Response
```json
{
    "success": false,
    "statusCode": 555,
    "data": "World",
    "errors": [
        {
            "code": 401,
            "message": "This is error"
        }
    ],
    "warnings": []
}
```

## Related

- [The global object g](https://docs.apimaker.dev/v1/docs/pre-defined-terms/global-object-g.html) · [Custom APIs](https://docs.apimaker.dev/v1/docs/apis-all/custom-apis/user-created-custom-api.html)
