# JSON Scalar throws 'couldNotConvert'

**URL:** <https://community.apollographql.com/t/json-scalar-throws-couldnotconvert/6731>\
**Category:** Client SDKs\
**Tags:** client, ios\
**Created:** [September 16, 2023, 8:07am UTC](https://community.apollographql.com/t/json-scalar-throws-couldnotconvert/6731 "2023-09-16T08:07:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javi\_Gallego](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/javi_gallego/32/1966_2.png) [@Javi\_Gallego](https://community.apollographql.com/u/Javi_Gallego)\
**Post date:** [September 16, 2023, 8:07am UTC](https://community.apollographql.com/t/json-scalar-throws-couldnotconvert/6731/1 "2023-09-16T08:07:40Z")

</div>

Hi,

I’m trying to fetch JSON Scalar data from an API, but it’s being decoded as a String and it fails. The data I’m waiting for is of type: **[String: Int]**.

This is the error message:

**couldNotConvert(value: AnyHashable([AnyHashable(“stringValue1”): AnyHashable(5), AnyHashable(“stringValue2”): AnyHashable(5), AnyHashable(“stringValue3”): AnyHashable(5), AnyHashable(“stringValue4”): AnyHashable(5), AnyHashable(“stringValue5”): AnyHashable(4), AnyHashable(“stringValue6”): AnyHashable(5), AnyHashable(“stringValue7”): AnyHashable(5), AnyHashable(“stringValue8”): AnyHashable(5), AnyHashable(“stringValue9”): AnyHashable(5), AnyHashable(“stringValue10”): AnyHashable(5)]), to: Swift.String)**

What can I do?

Thank you.

---

<div class="post-metadata">

**Author:** ![ZachF-Apollo](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/zachf-apollo/32/4210_2.png) [@ZachF-Apollo](https://community.apollographql.com/u/ZachF-Apollo)\
**Post date:** [September 18, 2023, 2:28pm UTC](https://community.apollographql.com/t/json-scalar-throws-couldnotconvert/6731/2 "2023-09-18T14:28:47Z")

</div>

@Javi_Gallego By default the extension generated for a custom scalar has it as a `String` however you can customize that extension to match whatever type you need and handle the decoding. Our docs page [here](https://www.apollographql.com/docs/ios/custom-scalars) has some examples of how to do this.

---

<div class="post-metadata">

**Author:** ![Justin\_Gonzalez](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/justin_gonzalez/32/5359_2.png) [@Justin\_Gonzalez](https://community.apollographql.com/u/Justin_Gonzalez)\
**Post date:** [February 6, 2025, 8:48pm UTC](https://community.apollographql.com/t/json-scalar-throws-couldnotconvert/6731/3 "2025-02-06T20:48:17Z")

</div>


