String

struct String

Adds MapKey support to a String. The string will be parsed into a MapKey by pulling out all key parts in the string. Key parts are seperated using ..

For example, the string first.second[].third will be converted to the following key parts: 1 KeyPart.object("first") 2 KeyPart.array("second") 3 KeyPart.object("third")

This key can be used to return the value My Value, from third in the following JSON dictionary:

{
   "first": {
       "second": [
           {
               "third": "My Value"
           }
       ]
   }
}

Using this key when storing a value in the map will, on the other hand create the above dictionary.

  • Parses the string into key parts seperated by a .. Throws an error if the string is badly formatted.

    Declaration

    Swift

    public func parseKeyParts() throws -> [KeyPart]
  • Returns itself.

    Declaration

    Swift

    public var rawValue: String { get }