JWJSONParser

@objcMembers
final public class JWJSONParser : NSObject

This JSON parser helps to convert a json object into a JWPlayerConfiguration using the different configuration builders provided by JWPlayerKit.

  • Convert the content of a file into a JWPlayerConfiguration.

    Note

    The provided file must follow a proper JSON format.

    Throws

    An error if the file can not be converted properly.

    Declaration

    Swift

    @objc(configFromUrl:error:)
    public static func config(from url: URL) throws -> JWPlayerConfiguration

    Parameters

    url

    The URL to read.

    Return Value

    A JWPlayerConfiguration used to configure a JWPlayer.

  • Convert a JSON object into a JWPlayerConfiguration.

    Throws

    An error if the json data can not be converted properly.

    Declaration

    Swift

    @objc(configFromJSONData:error:)
    public static func config(from jsonData: Data) throws -> JWPlayerConfiguration

    Parameters

    jsonData

    The JSON data.

    Return Value

    A JWPlayerConfiguration used to configure a JWPlayer.

  • Convert a JSON array into an array of JWPlayerItem objects.

    Note

    The expected JSON format follows the JW Platform Delivery API playlist structure. Items that fail to parse are silently skipped.

    Throws

    An error if the json data can not be converted properly.

    Declaration

    Swift

    @objc(playlistItemsFromJSONData:error:)
    public static func playlistItems(from jsonData: Data) throws -> [JWPlayerItem]

    Parameters

    jsonData

    The JSON data representing an array of playlist item objects.

    Return Value

    An array of JWPlayerItem used to load a playlist into a JWPlayer.