Xbasic
Extension::JsonTemplateReplace Method
Syntax
.TemplateReplace as c (json as C, namedResource as C [, variables as A [, args as P]])
Arguments
- jsonCharacter
Json to process
- namedResourceCharacter
named resource to use for named resource credentail template entries.
- variablesAny Type
Variables (properties or json) to replace in template.
- argsPointer
Arguments to replace in template.
Returns
- resultCharacter
Returns processed JSON
Description
Replace template values embedded in JSON values.
Discussion
Json TemplateReplace is the front end for extension::Curl::RequestTemplate(), but doesn't make a request.
If You want to see the request with replacements before it is posted to curl, you can use extension::json::TemplateReplace, then pass the returned JSON to the extension::Curl::Request()
Example
dim json as c = <<%json% { firstname : "{firstname}", lastname : "{lastname}", city : ":city" } %json% dim obj.firstname as c = "fred" dim obj.lastname as c = "jones" dim args as sql::Arguments args.Add("city","Boston") ? extension::json::TemplateReplace(json,"",obj,args) = { "firstname" : "fred", "lastname" : "jones", "city" : "Boston" }