# Import a JSON file?

**URL:** <https://discuss.elastic.co/t/import-a-json-file/192872>\
**Category:** Elasticsearch\
**Created:** [July 30, 2019, 10:34am UTC](https://discuss.elastic.co/t/import-a-json-file/192872 "2019-07-30T10:34:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticHT](https://avatars.discourse-cdn.com/v4/letter/e/9de0a6/32.png) [@elasticHT](https://discuss.elastic.co/u/elasticHT)\
**Post date:** [July 30, 2019, 10:34am UTC](https://discuss.elastic.co/t/import-a-json-file/192872/1 "2019-07-30T10:34:36Z")

</div>

After searching posts like this one:

> <https://stackoverflow.com/questions/15936616/import-index-a-json-file-into-elasticsearch>

I am still unable to import a JSON file. It seems that the file needs to be specially formatted in some way with a "type" prefix or similar (but where?).

My JSON file is a simple collection of documents like this:

{  
"Date": "some date",  
"Error: "an errror a user got",  
"Details" : "error details"  
}

**Tried this syntax:**  
curl -s -XPOST localhost:9200/\_bulk --data-binary @"/Users/me/Desktop/errorlog.json"

**And this one:**  
$ curl -XPOST '[http://localhost:9200/usserrorlogs/\_doc/1](http://localhost:9200/usserrorlogs/_doc/1)' -d @"/Users/me/Desktop/errorlog.json"

* * *

Do I need to pre-process the JSON first?

Thanks,

---

<div class="post-metadata">

**Author:** ![Gidi\_Kalef](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gidi_kalef/32/43651_2.png) [@Gidi\_Kalef](https://discuss.elastic.co/u/Gidi_Kalef)\
**Post date:** [July 30, 2019, 4:11pm UTC](https://discuss.elastic.co/t/import-a-json-file/192872/2 "2019-07-30T16:11:39Z")

</div>

your json miss double quotes in Details value

---

<div class="post-metadata">

**Author:** ![elasticHT](https://avatars.discourse-cdn.com/v4/letter/e/9de0a6/32.png) [@elasticHT](https://discuss.elastic.co/u/elasticHT)\
**Post date:** [July 30, 2019, 7:21pm UTC](https://discuss.elastic.co/t/import-a-json-file/192872/3 "2019-07-30T19:21:51Z")

</div>

Sorry, that was just a handwritten example (now corrected above). The actual JSON has the correct quotes.

Thanks,

---

<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:** [August 27, 2019, 7:21pm UTC](https://discuss.elastic.co/t/import-a-json-file/192872/4 "2019-08-27T19:21:57Z")

</div>

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