# Insert message does not work for JSON topic in Lenses - "does not have a schema for the Value"

**URL:** <https://ask.lenses.io/t/insert-message-does-not-work-for-json-topic-in-lenses-does-not-have-a-schema-for-the-value/21>\
**Category:** Lenses\
**Created:** [April 4, 2023, 10:52am UTC](https://ask.lenses.io/t/insert-message-does-not-work-for-json-topic-in-lenses-does-not-have-a-schema-for-the-value/21 "2023-04-04T10:52:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marios](https://dub1.discourse-cdn.com/flex017/user_avatar/ask.lenses.io/marios/32/8_2.png) [@Marios](https://ask.lenses.io/u/Marios)\
**Post date:** [April 4, 2023, 10:52am UTC](https://ask.lenses.io/t/insert-message-does-not-work-for-json-topic-in-lenses-does-not-have-a-schema-for-the-value/21/1 "2023-04-04T10:52:05Z")

</div>

_[Lenses.io](http://Lenses.io) created this topic as part of the seeding process for our community_

We have a Kafka topic named `test`, with a key type of `string`, and value type of `JSON`.  
When we try to insert messages into a valid JSON message, like the one below, Lenses gives out the following error:

```
Cannot insert data. `TableName(test)` does not have a schema for the Value.

```

This is what we use as the entry:

```auto
[
  {
    "key": "user1",
    "value": {
      "name": "John Doe",
      "email": "john.doe@example.com",
      "address": {
          "street": "123 Main St",
          "city": "Anytown",
          "state": "CA",
          "zip": "12345"
      },
      "phone_numbers": [
          {"type": "home", "number": "555-1234"},
          {"type": "work", "number": "555-5678"}
      ]
    }
  }
]

```

---

<div class="post-metadata">

**Author:** ![Marios](https://dub1.discourse-cdn.com/flex017/user_avatar/ask.lenses.io/marios/32/8_2.png) [@Marios](https://ask.lenses.io/u/Marios)\
**Post date:** [April 4, 2023, 11:02am UTC](https://ask.lenses.io/t/insert-message-does-not-work-for-json-topic-in-lenses-does-not-have-a-schema-for-the-value/21/2 "2023-04-04T11:02:06Z")

</div>

Starting with Lenses 5.0, we consciously decided to enforce schema validation for JSON-serialized keys and values, just like we do for their AVRO counterparts.

Whilst this choice may be inconvenient sometimes, it will protect you from inserting messages that can break your streaming pipelines or consumer code.

In your case, you must visit the _Schema_ tab of the `test` topic and add a schema like the one below for the topic’s value field. The schema must be in AVRO format:

```auto
{
  "type": "record",
  "name": "Person",
  "namespace": "example",
  "fields": [
    {
      "name": "name",
      "type": "string"
    },
    {
      "name": "email",
      "type": "string"
    },
    {
      "name": "address",
      "type": {
        "type": "record",
        "name": "Address",
        "fields": [
          {
            "name": "street",
            "type": "string"
          },
          {
            "name": "city",
            "type": "string"
          },
          {
            "name": "state",
            "type": "string"
          },
          {
            "name": "zip",
            "type": "string"
          }
        ]
      }
    },
    {
      "name": "phone_numbers",
      "type": {
        "type": "array",
        "items": {
          "type": "record",
          "name": "PhoneNumber",
          "fields": [
            {
              "name": "type",
              "type": "string"
            },
            {
              "name": "number",
              "type": "string"
            }
          ]
        }
      }
    }
  ]
}

```

Best,  
Marios

---

<div class="post-metadata">

**Author:** ![guillaume.ayme](https://dub1.discourse-cdn.com/flex017/user_avatar/ask.lenses.io/guillaume.ayme/32/64_2.png) [@guillaume.ayme](https://ask.lenses.io/u/guillaume.ayme)\
**Post date:** [April 4, 2023, 5:15pm UTC](https://ask.lenses.io/t/insert-message-does-not-work-for-json-topic-in-lenses-does-not-have-a-schema-for-the-value/21/3 "2023-04-04T17:15:34Z")

</div>

If it’s easier, you can create the Lenses schema in Lenses using a SQL CREATE TABLE command. Eg:

```auto
CREATE TABLE 
   test
     (_key string, name string, email string, address.street string, address.city string,address.state string, address.zip string, phone_numbers.type string[], phone_numbers.number string[])
FORMAT 
   (string, json)
PROPERTIES 
   (partitions=1, compacted=false);

```

And then insert

```auto
INSERT INTO test
 (_key, name, email, address.street, address.city, address.state, address.zip, phone_numbers.type, phone_numbers.number)
   VALUES
   ("user1","John Doe","john.doe@example.com","123 Main St","Anytown", "CA", "12345", ["home","work"], ["555-1234","555-5678"])

```

(not exactly the same array structure for phone\_numbers, maybe someone else can correct this)

---

<div class="post-metadata">

**Author:** ![stefanbot](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@stefanbot](https://ask.lenses.io/u/stefanbot)\
**Post date:** [July 22, 2024, 8:16am UTC](https://ask.lenses.io/t/insert-message-does-not-work-for-json-topic-in-lenses-does-not-have-a-schema-for-the-value/21/4 "2024-07-22T08:16:24Z")

</div>

Lenses 5.5.4 now has the option to disable schema validation when inserting JSON messages via Lenses
