# NEST: Is it possible / could it be made possible to load json file into an ISearchRespone object?

**URL:** <https://discuss.elastic.co/t/nest-is-it-possible-could-it-be-made-possible-to-load-json-file-into-an-isearchrespone-object/50165>\
**Category:** Elasticsearch\
**Created:** [May 16, 2016, 11:36pm UTC](https://discuss.elastic.co/t/nest-is-it-possible-could-it-be-made-possible-to-load-json-file-into-an-isearchrespone-object/50165 "2016-05-16T23:36:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![scottk\_1](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@scottk\_1](https://discuss.elastic.co/u/scottk_1)\
**Post date:** [May 16, 2016, 11:36pm UTC](https://discuss.elastic.co/t/nest-is-it-possible-could-it-be-made-possible-to-load-json-file-into-an-isearchrespone-object/50165/1 "2016-05-16T23:36:45Z")

</div>

I currently am running queries using NEST (ElasticClient.Search), but I don't do anything with the response objects, I just store the returned JSON.

The reason for this is that just storing statistics is much smaller then keeping around all the data in the ElasticSearch indexes.

At some point later, someone can come along and query the statistics I've stored to disks, but ideally the server would take the JSON file and process it first before displaying it in the UI.

Is there some way to simply load into the ISearchResult object just from the JSON I've stored to disk?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [May 17, 2016, 3:12am UTC](https://discuss.elastic.co/t/nest-is-it-possible-could-it-be-made-possible-to-load-json-file-into-an-isearchrespone-object/50165/2 "2016-05-17T03:12:04Z")

</div>

Yes. If you know the type `T` that is represented in the json documents then you can use

```auto
SearchResponse<T> searchResponse = null;

using (var stream = File.OpenRead("path-to-json.json"))
{
    searchResponse = client.Serializer.Deserialize<SearchResponse<T>>(stream);
}

```

if you don't know the type, then you can use `dynamic`, which will deserialize each document to a [Json.Net](http://Json.Net) `JObject`

```auto
SearchResponse<dynamic> searchResponse = null;

using (var stream = File.OpenRead("path-to-json.json"))
{
    searchResponse = client.Serializer.Deserialize<SearchResponse<dynamic>>(stream);
}

```

---

<div class="post-metadata">

**Author:** ![scottk\_1](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@scottk\_1](https://discuss.elastic.co/u/scottk_1)\
**Post date:** [May 17, 2016, 6:32pm UTC](https://discuss.elastic.co/t/nest-is-it-possible-could-it-be-made-possible-to-load-json-file-into-an-isearchrespone-object/50165/3 "2016-05-17T18:32:06Z")

</div>

Thank you!

Random asides:

- I did check that the serialized response object and the deserizalized and re-serialized response object from the response json on disk were the same. Check!
- In my cases, the serialized response object is about four times the size of the response json.

Super helpful thanks again!

---

<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:** [July 5, 2017, 10:50pm UTC](https://discuss.elastic.co/t/nest-is-it-possible-could-it-be-made-possible-to-load-json-file-into-an-isearchrespone-object/50165/4 "2017-07-05T22:50:53Z")

</div>


