MarkLogic Connect
MarkLogic Connect Client API Collection
List of all members
mlclient::utilities::CppRestJsonHelper Class Reference

This class provides utility functions to handle JSON data. More...

#include <CppRestJsonHelper.hpp>

Static Public Member Functions

cpprestjsonhelper_documentconversion IDocumentContent conversion functions
static MLCLIENT_API ITextDocumentContenttoDocument (web::json::value &json)
 Creates a IDocumentContent instance based on a cpprest API web::json::value instance. More...
 
static MLCLIENT_API ITextDocumentContenttoDocument (const Response &resp)
 Converts the Response directory to an ITextDocumentContent instance. More...
 
static MLCLIENT_API const web::json::value fromDocument (const IDocumentContent &doc)
 Creates a web::json::value from a IDocumentContent instance. More...
 
static MLCLIENT_API const web::json::value fromDocument (const CppRestJsonDocumentContent &doc)
 Creates a web::json::value from a CppRestJsonDocumentContent instance. More...
 
cpprestjsonhelper_responseconversion Response conversion functions
static MLCLIENT_API web::json::value fromResponse (const Response &resp)
 Creates a web::json::value from a Response object. More...
 
static MLCLIENT_API PermissionSet permissionsFromResponse (const Response &resp)
 Extracts a PermissionSet from a document metadata fetch response. More...
 

Detailed Description

This class provides utility functions to handle JSON data.

Author
Adam Fowler adam..nosp@m.fowl.nosp@m.er@ma.nosp@m.rklo.nosp@m.gic.c.nosp@m.om
Since
8.0.0
Date
2016-04-25

This is a non-instantiable class with static functions to handle conversion of data between raw cpprest web::json::value and IDocumentContent objects.

The fromResponse and toDocument functions are particularly useful when extracting information from a Response object.

This class uses the CppRestJsonDocumentContent instance to directly wrap an underlying web::json::value instance.

Note
This class has an external dependency on Microsoft's C++ cpprest API. As this API is required to use MarkLogic's C++ wrapper (this API) , this does not introduce any extra dependencies.

Member Function Documentation

static MLCLIENT_API const web::json::value mlclient::utilities::CppRestJsonHelper::fromDocument ( const IDocumentContent doc)
static

Creates a web::json::value from a IDocumentContent instance.

Warning
Don't call this on a CppRestJsonDocumentContent instance - use CppRestJsonDocumentContent::getJson() instead
Exceptions
AnInvalidFormatException if the document does not have the mime type of application/json, or if there is a parse error.
Parameters
docThe IDocumentContent instance to create a web::json::value from.
Returns
A Microsoft cpprest API web::json::value instance created from the IDocumentContent.
static MLCLIENT_API const web::json::value mlclient::utilities::CppRestJsonHelper::fromDocument ( const CppRestJsonDocumentContent doc)
static

Creates a web::json::value from a CppRestJsonDocumentContent instance.

This is very efficient as the CppRestJsonDocumentContent effectively just wraps a web::json::value

Parameters
docthe CppRestJsonDocumentContent instance to extract the web::json::value from
Returns
A Microsoft cpprest API web::json::value instance extracted from the CppRestJsonDocumentContent.
Since
8.0.2
static MLCLIENT_API web::json::value mlclient::utilities::CppRestJsonHelper::fromResponse ( const Response resp)
static

Creates a web::json::value from a Response object.

Exceptions
AnInvalidFormatException if the document does not have the mime type of application/json, or if there is a parse error.
Parameters
respThe Response instance to create a web::json::value from.
Returns
A Microsoft cpprest API web::json::value instance created from the Response.
static MLCLIENT_API PermissionSet mlclient::utilities::CppRestJsonHelper::permissionsFromResponse ( const Response resp)
static

Extracts a PermissionSet from a document metadata fetch response.

Exceptions
AnInvalidFormatException if the document does not have the mime type of application/json, or if there is a parse error.
Parameters
respThe Response instance to create a web::json::value from.
Returns
The PermissionSet extracted from the response
Note
PermissionSet is a typedef for std::vector<Permission>.
Since
8.0.2
static MLCLIENT_API ITextDocumentContent* mlclient::utilities::CppRestJsonHelper::toDocument ( web::json::value &  json)
static

Creates a IDocumentContent instance based on a cpprest API web::json::value instance.

Note
Actually returns a CppRestJsonDocumentContent instance (A subclass of TextDocumentContent)
Parameters
jsonThe web::json::value to create a IDocumentContent representation of
Returns
A IDocumentContent instance wrapping the value
static MLCLIENT_API ITextDocumentContent* mlclient::utilities::CppRestJsonHelper::toDocument ( const Response resp)
static

Converts the Response directory to an ITextDocumentContent instance.

Since
8.0.2
Date
2016-07-30
Parameters
respThe Response instance to create a web::json::value from.
Returns
A ITextDocumentContent instance representing the response

The documentation for this class was generated from the following file: