# Parse JSON with non-string key values

**URL:** <https://forums.swift.org/t/parse-json-with-non-string-key-values/47197>\
**Category:** Using Swift\
**Created:** [April 6, 2021, 1:58pm UTC](https://forums.swift.org/t/parse-json-with-non-string-key-values/47197 "2021-04-06T13:58:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bcardarella](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/bcardarella/32/15751_2.png) [@bcardarella](https://forums.swift.org/u/bcardarella)\
**Post date:** [April 6, 2021, 1:58pm UTC](https://forums.swift.org/t/parse-json-with-non-string-key-values/47197/1 "2021-04-06T13:58:25Z")

</div>

Is it possible to parse JSON with `JSONSerialization` and have a hash of `[AnyHashable:Any]` instead of `[String:Any]`? I would guess the ability to do this is with the `readingOptions` but I cannot find any good documentation on this anywhere.

The example payload I have would be:

```swift
{
  0: [1,2,3],
  1: "foobar",
  2: {
    0: 1
  }
  "a": 123
}

```

So the resulting key types are restricted to just `String` and `Int` but the value types could be `String`, `Int`, `Array<Any>`, and `[AnyHashable:Any]`

---

<div class="post-metadata">

**Author:** ![lukasa](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lukasa/32/1232_2.png) [@lukasa](https://forums.swift.org/u/lukasa)\
**Post date:** [April 6, 2021, 2:50pm UTC](https://forums.swift.org/t/parse-json-with-non-string-key-values/47197/2 "2021-04-06T14:50:25Z")

</div>

The format you are describing is not JSON. JSON requires string keys and always has.
