ToJSON
public class ToJSON
A utility class for formatting OData values as JSON strings.
-
Undocumented
Declaration
Swift
public static func complexList<C>(value: Array<C>) -> String where C : ComplexValue
-
Undocumented
Declaration
Swift
public static func complexList<C>(value: Array<C>, options: Int = (0 as Int)) -> String where C : ComplexValue
-
Undocumented
Declaration
Swift
public static func entityList<E>(value: Array<E>) -> String where E : EntityValue
-
Undocumented
Declaration
Swift
public static func entityList<E>(value: Array<E>, options: Int = (0 as Int)) -> String where E : EntityValue
-
Format a complex value as a JSON string, including structural and navigation properties.
Declaration
Swift
public static func complex(_ value: ComplexValue, options: Int = (0 as Int)) -> String
Parameters
value
Complex value.
options
Additional bind options. See
DataContext
constants.Return Value
JSON string.
-
Format a complex list as a JSON string, including structural and navigation properties.
Declaration
Swift
public static func complexList(_ value: ComplexValueList, options: Int = (0 as Int)) -> String
Parameters
value
Complex list.
options
Additional bind options. See
DataContext
constants.Return Value
JSON string.
-
Convert
value
to OData 4.0 JSON format, then convert to a data URI with media type “application/json” and base64-encoded data.Declaration
Swift
public static func dataURI(_ value: AnyObject?) -> String
Parameters
value
Header value.
Return Value
Data URI.
-
Format an entity value as a JSON string, including structural and navigation properties.
Example using proxy classes
open func jsonEntityExample() throws -> Void { let service = self.service let customer = Customer(withDefaults: false) customer.customerID = "123" customer.contactName = "Four Five Six" customer.companyName = "JSON Inc." customer.oldEntity = customer.copy() customer.old.contactName = "One Two Three" self.showCustomer(customer) let json = ToJSON.entity(customer) try Example.show(json) let restoredCustomer = try service.fetchCustomer(matching: FromJSON.entity(json)) self.showCustomer(restoredCustomer) assert(StringOperator.equal(customer.toString(), restoredCustomer.toString())) assert(StringOperator.equal(customer.old.toString(), restoredCustomer.old.toString())) }
Declaration
Swift
public static func entity(_ value: EntityValue, options: Int = (0 as Int)) -> String
Parameters
value
Entity value.
options
Additional bind options. See
DataContext
constants.Return Value
JSON string.
-
Format an entity value as a JSON string, including only key properties.
Declaration
Swift
public static func entityKey(_ value: EntityValue, options: Int = (0 as Int)) -> String
Parameters
value
Entity value.
options
Additional bind options. See
DataContext
constants.Return Value
JSON string.
-
Format an entity list as a JSON string, including structural and navigation properties.
Declaration
Swift
public static func entityList(_ value: EntityValueList, options: Int = (0 as Int)) -> String
Parameters
value
Entity list.
options
Additional bind options. See
DataContext
constants.Return Value
JSON string.