# How to story a JSON Array in an index via the Java client?

**URL:** <https://discuss.elastic.co/t/how-to-story-a-json-array-in-an-index-via-the-java-client/349390>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [December 14, 2023, 4:25pm UTC](https://discuss.elastic.co/t/how-to-story-a-json-array-in-an-index-via-the-java-client/349390 "2023-12-14T16:25:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Itsman-AT](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/itsman-at/32/130022_2.png) [@Itsman-AT](https://discuss.elastic.co/u/Itsman-AT)\
**Post date:** [December 14, 2023, 4:25pm UTC](https://discuss.elastic.co/t/how-to-story-a-json-array-in-an-index-via-the-java-client/349390/1 "2023-12-14T16:25:45Z")

</div>

I am trying to store a JSON array (coming from an SQL Table field) within an Elasticsearch index. The JSON Array coming from the DB looks like this:

```auto
["Texas", "Texas", "Sidebet City"]

```

I get this array as a String from the database and I want to store this String as a JSON Array in an Elasticsearch index (knowing that Elasticsearch only knows Integer and String data types). When I try to use the following code of the Elasticsearch Java Client (v8.11) via storing the String value in a document object:

```auto
   for (CrawlingEntry crawlingEntry : crawlingEntries) {
        br.operations(op -> op
                .index(idx -> idx
                        .index(tableName)
                        .id(crawlingEntry.geturl_id().toString())
                        .document(crawlingEntry)
                )
        );

```

I see that the Array is stored with escape characters within the created index (and with outer parentheses):

```auto
 "locations": "[\"Texas\", \"Texas\", \"Sidebet City\"]"

```

What I need is this representation, though:

```auto
"locations": ["Texas", "Texas", "Sidebet City"]

```

**(note the missing outer parentheses)**

Is this actually possible with the Java client? How can I achieve this representation?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 11, 2024, 4:25pm UTC](https://discuss.elastic.co/t/how-to-story-a-json-array-in-an-index-via-the-java-client/349390/2 "2024-01-11T16:25:54Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
