---
title: "Magento 2.4.6. Unable to output data to json"
description: "I have a problem with the json output when sending a request to the API. I receive data in this format: &quot;{\n \&quot;name\&quot;: \&quot;John\&quot;,\n \&quot;age\&quot;: 30,\n \&quot;car\&quot;:..."
url: https://extraproxies.com/magento-2-4-6-unable-to-output-data-to-json
date: 2023-10-18
modified: 2023-10-18
author: "ExtraProxies"
tags: ["2.4.6.", "Data", "json", "Magento", "output", "Unable"]
type: post
lang: en
---

# Magento 2.4.6. Unable to output data to json

I have a problem with the json output when sending a request to the API.

I receive data in this format:

```
"{\n    \"name\": \"John\",\n    \"age\": 30,\n    \"car\": null,\n   \"address\": {\n        \"street\": \"123 Main St\",\n        \"city\": \"Anytown\",\n        \"zip\": \"12345\"\n    }\n}"
```

I need the data in this format:

```
{     "name": "John",     "age": 30,     "car": null,     "address": {         { "street": "123 Main St",         "city": "Anytown",         "zip": "12345"     } }
```

Am I correct in understanding that this is because I am using such an interface on my side?

```
namespace Dev\RestApi\Api;  interface TestInterface {     /**     *     * @return string     */     public function testMethod(); }
```

My Model:

```
namespace Dev\RestApi\Model;  use Dev\RestApi\Api\TestInterface;  class TestModel implements TestInterface {     public function testMethod()     {          $  data = [             'name' => 'John',             'age' => 30,             'car' => null,             'some' => null,             'address' => [                 'street' => '123 Main St',                 'city' => 'Anytown',                 'zip' => '12345'             ]         ];          $  jsonResponse = json_encode($  data, JSON_PRETTY_PRINT);          return $  jsonResponse;     } }
```
