ToJSON
public class ToJSON
A utility class for formatting OData values as JSON strings.
-
Undocumented
Declaration
Swift
public static func complexList<C:ComplexValue>(value: Array<C>) -> String
-
Undocumented
Declaration
Swift
public static func complexList<C:ComplexValue>(value: Array<C>, options: Int = (0 as Int)) -> String
-
Undocumented
Declaration
Swift
public static func entityList<E:EntityValue>(value: Array<E>) -> String
-
Undocumented
Declaration
Swift
public static func entityList<E:EntityValue>(value: Array<E>, options: Int = (0 as Int)) -> String
-
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.
-
Format an entity value as a JSON string, including structural and navigation properties.
Example using proxy classes
open func jsonEntityExample() throws -> Void { defer { DebugConsole.traceOut("example.NorthwindProxyClient.jsonEntityExample") } do { DebugConsole.traceIn("example.NorthwindProxyClient.jsonEntityExample") do { 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 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.