<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/JSONDecoder/assumesTopLevelDictionary",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation11JSONDecoderC25assumesTopLevelDictionarySbvp"
  },
  "title" : "assumesTopLevelDictionary"
}
-->

# assumesTopLevelDictionary

Specifies that decoding assumes the top level of the JSON data is a dictionary, even if it doesn’t begin and end with braces.

```
var assumesTopLevelDictionary: Bool { get set }
```

## Discussion

This is an extension to JSON5 that’s not part of the specification. [`AttributedString`](/documentation/Foundation/AttributedString) uses this option, along with [`allowsJSON5`](/documentation/Foundation/JSONDecoder/allowsJSON5), to support the use of JSON5 inside Markdown strings that use multiple custom attributes. Using [`assumesTopLevelDictionary`](/documentation/Foundation/JSONDecoder/assumesTopLevelDictionary) allows for the following syntax inside the parentheses of the custom attribute markup:

```swift
This is a [Markdown](https://commonmark.org) string with a ^[custom attribute](factor: 10, other: true).
```

Without [`assumesTopLevelDictionary`](/documentation/Foundation/JSONDecoder/assumesTopLevelDictionary), the markup would have to use explicit enclosing braces to declare the contents of the parentheses to be a dictionary:

```swift
This is a [Markdown](https://commonmark.org) string with a ^[custom attribute]({factor: 10, other: true}).
```

When you use braces, you must use matched pairs. This means that with [`assumesTopLevelDictionary`](/documentation/Foundation/JSONDecoder/assumesTopLevelDictionary) set, the syntax `({…})` and `(…)` are both legal, but `({…)` and `(…})` are not.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)