# Force field empty array to an empty object

**URL:** <https://discuss.elastic.co/t/force-field-empty-array-to-an-empty-object/81442>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [April 6, 2017, 10:08am UTC](https://discuss.elastic.co/t/force-field-empty-array-to-an-empty-object/81442 "2017-04-06T10:08:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [April 6, 2017, 10:08am UTC](https://discuss.elastic.co/t/force-field-empty-array-to-an-empty-object/81442/1 "2017-04-06T10:08:24Z")

</div>

We use Php to send JSON to elasticsearch, as such, we have sometime "" as en empty field that is mapped as an object (with sometimes data in it, sometimes not).

```
[
  {
    "_source": {
      "data": {
        "toto": 1
      },
      "hello": "worl"
    }
  },
  {
    "_source": {
      "data": {},
      "hello": "worl"
    }
  },
  {
    "_source": {
      "data": [],
      "hello": "world"
    }
  }
]

```

Using Spark and es4Hadoop:

```
sql.read.format("org.elasticsearch.spark.sql").options(

).load("test/events").foreach(println)

```

> java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.Long

error

---

<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:** [May 4, 2017, 10:08am UTC](https://discuss.elastic.co/t/force-field-empty-array-to-an-empty-object/81442/2 "2017-05-04T10:08:35Z")

</div>

Closed on May 4, 2017, 10:08am UTC

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