pips_multimap_add_json()

Updated: April 19, 2023

Map a key to a JSON object

Synopsis:

#include <pips/multimap.h>
int pips_multimap_add_json(pips_multimap_t *multimap,
                           const char *key,
                           const char *json_data)

Arguments:

multimap
The multimap instance in which the new mapping (item) is being created
key
The key to assign to the mapping
json_data
A JSON object encoded as a NULL-terminated character string

Library:

pips-client

Description:

This function creates a mapping in the current multimap instance by associating a JSON object with the given key. The mapping is created only if the given key is not already mapped to another value, so this function cannot be used to update a key's value, only to create a new mapping.

Returns:

0
The mapping was created successfully
-1
An error prevented the creation of the new mapping (errno is set)

Errors:

  • EEXIST: The multimap already contains a mapping for the given key.
  • EINVAL: The multimap instance is not valid.
  • ENOMEM: There was not enough memory to allocate a new mapping.