Instance Methodgrdb 7.3.0GRDB
jsonRepresentation(atPath:)
Returns a valid JSON string with the ->
SQL operator.
- iOS
- 16+
- macOS
- 13.2+
- tvOS
- 17+
- watchOS
- 9+
func jsonRepresentation(atPath path: some SQLExpressible) -> SQLExpression
Parameters
For example:
let info = JSONColumn("info")
// SELECT info -> 'firstName' FROM player
// → '"Arthur"'
let name = try Player
.select(info.jsonRepresentation(atPath: "firstName"), as: String.self)
.fetchOne(db)
// SELECT info -> 'address' FROM player
// → '{"street":"Rue de Belleville","city":"Paris"}'
let name = try Player
.select(info.jsonRepresentation(atPath: "address"), as: String.self)
.fetchOne(db)
Related SQL documentation: https://www.sqlite.org/json1.html#jptr