Extension::JsonOffsetToPath Method
Syntax
.OffsetToPath as c (json as C, offset as N [, base as N])
Arguments
- json
Json String to get a path from.
- offset
Offset within the json string.
- base
Optional Array/ String position base, defaults to 1.
Description
Convert the location in a json string to a 'path'. The 'base' argument indicates array/position start - Xbasic should be 1, javascript should be 0.
Discussion
In the following example, the string "NY" is searched for usig the at() command, and given the position within the string that is returned, return the path that contains the element.
Example
dim json as c = <<%json% { "fname": "john", "lname": "public", "address": { "address1": "12 main street", "address2": "apt 2b", "state": "NY", "city": "Springfield" }, "bill_address": { "address1": "12 main street", "address2": "apt 2b", "state": "NY", "city": "Statesville" } } %json% ? extension::json::OffsetToPath(json, at("\"NY\"",json) ) = "address.state"