# Deserialize different typed field to other typed property in Nest

**URL:** <https://discuss.elastic.co/t/deserialize-different-typed-field-to-other-typed-property-in-nest/283159>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [September 2, 2021, 10:54am UTC](https://discuss.elastic.co/t/deserialize-different-typed-field-to-other-typed-property-in-nest/283159 "2021-09-02T10:54:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Leonard\_Sart1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/martin_leonard_sart1/32/94079_2.png) [@Martin\_Leonard\_Sart1](https://discuss.elastic.co/u/Martin_Leonard_Sart1)\
**Post date:** [September 2, 2021, 10:54am UTC](https://discuss.elastic.co/t/deserialize-different-typed-field-to-other-typed-property-in-nest/283159/1 "2021-09-02T10:54:34Z")

</div>

Hi,  
We just recently upgraded from 6.3 to 7.7 version of Elasticsearch.

Upon migration, we got an error something like this:  
"{"expected:'Number Token', actual:'"10"' at offset:458"}"

Based on a blog I've read, bluewalk replied to the problem was:

\*Seems the new serializer takes the property datatype for deserialization, as this was defined as long instead of string the deserializer failed. \*  
_Can be closed 🙂_

Now, is there a way to deserialize object field that has been mapped in the index as "Text" to "integer" or other type in Nest? And can you give me an example on implementing it.

Thanks and regards,  
Martin

---

<div class="post-metadata">

**Author:** ![stevejgordon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stevejgordon/32/80912_2.png) [@stevejgordon](https://discuss.elastic.co/u/stevejgordon)\
**Post date:** [September 3, 2021, 2:56pm UTC](https://discuss.elastic.co/t/deserialize-different-typed-field-to-other-typed-property-in-nest/283159/2 "2021-09-03T14:56:21Z")

</div>

Hi Martin,

One option would be changing your POCO to reflect the property as a string. I presume that's not possible here for some reason? You could of course parse that to a long in a computed property if it's needed in that form.

You could also look at plugging in a [custom serialiser](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/custom-serialization.html) to control the behaviour for your types as you require. Using the [JSON.NET serialiser](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/custom-serialization.html#_jsonnetserializer) which handles string to numeric conversions will probably work.

Cheers,  
Steve

---

<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:** [October 1, 2021, 2:57pm UTC](https://discuss.elastic.co/t/deserialize-different-typed-field-to-other-typed-property-in-nest/283159/3 "2021-10-01T14:57:01Z")

</div>

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