topLevelDictionaryAssumed
Specifies that the parser assumes the top level of the JSON data is a dictionary, even if it doesn’t begin and end with curly braces.
Declaration
static var topLevelDictionaryAssumed: JSONSerialization.ReadingOptions { get }Discussion
This is an extension to JSON5 that isn’t part of the specification. AttributedString uses this option, along with json5Allowed, to support the use of JSON5 inside Markdown strings that use multiple custom attributes. Using topLevelDictionaryAssumed allows for the following syntax in the parentheses of the custom attribute markup:
This is a [Markdown](https://commonmark.org) string with a ^[custom attribute](factor: 10, other: true).Without topLevelDictionaryAssumed, the markup would have to use explicit enclosing braces to declare the contents of the parentheses to be a dictionary:
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 topLevelDictionaryAssumed set, the syntax ({…}) and (…) are both legal, but ({…) and (…}) are not.