|  | Home | Documentation | json.h File Reference updated by Robert van Engelen |

Functions
json.h File Reference
`#include "soapH.h"`
Include dependency graph for json.h:

## Functions

int | json_error (struct soap *soap, struct value *v)
| Set value to JSON error property given the context's error code, as per Google JSON Style Guide.
int | json_send_fault (struct soap *soap)
| Respond with a JSON error when an internal fault occurred (i.e. soap->error is nonzero), as per Google JSON Style Guide.
int | json_send_error (struct soap *soap, int status, const char *message, const char *details)
| Send JSON error back to the client using the specified HTTP status code and a message and details, as per Google JSON Style Guide.
int | json_write (struct soap *soap, const struct value *v)
| Write JSON value to the context's output (socket, stream, FILE, or string).
int | json_send (struct soap *soap, const struct value *v)
| Send JSON value, requires soap_begin_send() before this call and soap_end_send() to finish, this function is used by json_write().
int | json_read (struct soap *soap, struct value *v)
| Read JSON value from context's input (socket, stream, FILE, or string).
int | json_recv (struct soap *soap, struct value *v)
| Receive JSON value, requires soap_begin_recv() before this call and soap_end_recv() to finish, this function is used by json_read().
int | json_call (struct soap *soap, const char *endpoint, const struct value *in, struct value *out)
int | json_send_string (struct soap *soap, const char *s)
| Convert string to JSON string and write it to context's output.

## Function Documentation

## ◆ json_call()

int json_call | ( | struct soap * | soap,
|  | const char * | endpoint,
|  | const struct value * | in,
|  | struct value * | out )

extern

Client-side JSON REST call to endpoint URL with optional in and out values (POST with in/out, GET with out, PUT with in, DELETE without in/out), returns SOAP_OK or HTTP status code

Parameters

  soap | context that manages IO
  endpoint | URL of the JSON REST/RPC service
  in | value to send, or NULL (when non-NULL: PUT or POST, when NULL: GET or DELETE)
  out | value to receive, or NULL (when non-NULL: GET or POST, when NULL: PUT or DELETE)

Returns
  SOAP_OK or HTTP status code or an error code with out set to the JSON error property when the error was returned by the server

## ◆ json_error()

int json_error | ( | struct soap * | soap,
|  | struct value * | v )

extern

Set value to JSON error property given the context's error code, as per Google JSON Style Guide.

Parameters

  soap | context with soap->error set
  v | value to set

Returns
  error code

## ◆ json_read()

int json_read | ( | struct soap * | soap,
|  | struct value * | v )

extern

Read JSON value from context's input (socket, stream, FILE, or string).

Parameters

  soap | context that manages IO
  v | value to read (non NULL)

Returns
  SOAP_OK or error code

## ◆ json_recv()

int json_recv | ( | struct soap * | soap,
|  | struct value * | v )

extern

Receive JSON value, requires soap_begin_recv() before this call and soap_end_recv() to finish, this function is used by json_read().

Parameters

  soap | context that manages IO
  v | value to receive (non NULL)

Returns
  SOAP_OK or error code

## ◆ json_send()

int json_send | ( | struct soap * | soap,
|  | const struct value * | v )

extern

Send JSON value, requires soap_begin_send() before this call and soap_end_send() to finish, this function is used by json_write().

Parameters

  soap | context that manages IO
  v | value to send

Returns
  SOAP_OK or error code

## ◆ json_send_error()

int json_send_error | ( | struct soap * | soap,
|  | int | status,
|  | const char * | message,
|  | const char * | details )

extern

Send JSON error back to the client using the specified HTTP status code and a message and details, as per Google JSON Style Guide.

Parameters

  soap | context with soap->error set
  status | HTTP error status code or SOAP_OK (0)
  message | error message
  details | error detail or NULL

Returns
  error code

## ◆ json_send_fault()

int json_send_fault | ( | struct soap * | soap | ) |

extern

Respond with a JSON error when an internal fault occurred (i.e. soap->error is nonzero), as per Google JSON Style Guide.

Parameters

  soap | context with soap->error set

Returns
  error code

## ◆ json_send_string()

int json_send_string | ( | struct soap * | soap,
|  | const char * | s )

extern

Convert string to JSON string and write it to context's output.

Parameters

  soap | context that manages IO
  s | string to send

Returns
  SOAP_OK or error code

## ◆ json_write()

int json_write | ( | struct soap * | soap,
|  | const struct value * | v )

extern

Write JSON value to the context's output (socket, stream, FILE, or string).

Parameters

  soap | context that manages IO
  v | value to write

Returns
  SOAP_OK or error code