[#BloombergLP-bdljsn-Json-visit-0a] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdljsn.adoc[bdljsn]::xref:BloombergLP/bdljsn/Json.adoc[Json]::visit :relfileprefix: ../../../ :mrdocs: `visit` overloads == Synopses Declared in `<bdljsn_json.h>` Return the result (having a deduced type) of invoking the specified `visitor` (callable) object on this `Json` object. `visitor` must be callable as if it provides the following overloads of `operator()`, any of which can have deduced return types: ` decltype(auto) operator()(JsonObject *object ); decltype(auto) operator()(JsonArray *array ); decltype(auto) operator()(bsl::string *string ); decltype(auto) operator()(JsonNumber *number ); decltype(auto) operator()(bool *boolean); decltype(auto) operator()(JsonNull *null ); ` The overload corresponding to the current `type()` of this `Json` object is invoked. The behavior is undefined unless all of these six overloads are defined _and_ each has the same return type. The behavior is undefined if the `string` overload leaves this `Json` object with a string that is not valid UTF‐8. Note that overloads that are not applicable in a given application need not do anything other than return. Also note that if `visitor` is `const` qualified then each of its `operator()` overloads must also be `const` qualified. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class VISITOR> decltype(auto) xref:BloombergLP/bdljsn/Json/visit-01.adoc[visit](VISITOR&& visitor); ---- [.small]#xref:BloombergLP/bdljsn/Json/visit-01.adoc[_» more..._]# Return the result (having a deduced type) of invoking the specified `visitor` (callable) object on this `Json` object. `visitor` must be callable as if it provides the following overloads of `operator()`, any of which can have deduced return types: ` decltype(auto) operator()(const JsonObject& object ); decltype(auto) operator()(const JsonArray& array ); decltype(auto) operator()(const bsl::string& string ); decltype(auto) operator()(const JsonNumber& number ); decltype(auto) operator()(const bool& boolean); decltype(auto) operator()(const JsonNull& null ); ` The overload corresponding to the current `type()` of this `Json` object is invoked. The behavior is undefined unless all of these six overloads are defined _and_ each has the same return type. Note that overloads that are not applicable in a given application need not do anything other than return. Also note that if `visitor` is `const` qualified then each of its `operator()` overloads must also be `const` qualified. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class VISITOR> decltype(auto) xref:BloombergLP/bdljsn/Json/visit-0c.adoc[visit](VISITOR&& visitor) const; ---- [.small]#xref:BloombergLP/bdljsn/Json/visit-0c.adoc[_» more..._]# Return the result (having `RETURN_TYPE`) of invoking the specified `visitor` (callable) object on this `Json` object. `visitor` must be callable as if it provides the following overloads of `operator()`: ` RETURN_TYPE operator()(JsonObject *object ); RETURN_TYPE operator()(JsonArray *array ); RETURN_TYPE operator()(bsl::string *string ); RETURN_TYPE operator()(JsonNumber *number ); RETURN_TYPE operator()(bool *boolean); RETURN_TYPE operator()(JsonNull *null ); ` The overload corresponding to the current `type()` of this `Json` object is invoked. For C++03 `visitor` must be `const` qualified. The behavior is undefined unless all of these six overloads are defined. The behavior is undefined if the `string` overload leaves this `Json` object with a string that is not valid UTF‐8. Note that overloads that are not applicable in a given application need not do anything other than return. Also note that if `visitor` is `const` qualified then each of its `operator()` overloads must also be `const` qualified. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class RETURN_TYPE, class VISITOR> RETURN_TYPE xref:BloombergLP/bdljsn/Json/visit-02.adoc[visit](VISITOR&& visitor); ---- [.small]#xref:BloombergLP/bdljsn/Json/visit-02.adoc[_» more..._]# Return the result (having `RETURN_TYPE`) of invoking the specified `visitor` (callable) object on this `Json` object. `visitor` must be callable as if it provides the following overloads of `operator()`: ` RETURN_TYPE operator()(const JsonObject& object ); RETURN_TYPE operator()(const JsonArray& array ); RETURN_TYPE operator()(const bsl::string& string ); RETURN_TYPE operator()(const JsonNumber& number ); RETURN_TYPE operator()(const bool& boolean); RETURN_TYPE operator()(const JsonNull& null ); ` The overload corresponding to the current `type()` of this `Json` object is invoked. For C++03 `visitor` must be `const`‐qualified. The behavior is undefined unless all of these six overloads are defined. Note that overloads that are not applicable in a given application need not do anything other than return. Also note that if `visitor` is `const` qualified then each of its `operator()` overloads must also be `const` qualified. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class RETURN_TYPE, class VISITOR> RETURN_TYPE xref:BloombergLP/bdljsn/Json/visit-06.adoc[visit](VISITOR&& visitor) const; ---- [.small]#xref:BloombergLP/bdljsn/Json/visit-06.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#