C library to handle JSON formatted comments using the cJSON library

This commit is contained in:
Celine Mercier
2018-10-07 18:51:27 +02:00
parent 1b6b6d825a
commit 79f4185757
4 changed files with 3497 additions and 0 deletions

43
src/libjson/json_utils.h Normal file
View File

@@ -0,0 +1,43 @@
/********************************************************************
* Json utils header file *
********************************************************************/
/**
* @file json_utils.h
* @author Celine Mercier (celine.mercier@metabarcoding.org)
* @date 27 August 2018
* @brief Header file for the JSON utils functions.
*/
#ifndef JSON_UTILS_H_
#define JSON_UTILS_H_
#include <stdlib.h>
#include <stdint.h>
/**
* @brief Add a comment (in the key/value form) to a (JSON formatted) comments character string.
*
* @warning If the key is already in the structure, its associated value is turned
* into an array if needed and the new value is added to that array.
* // TODO discuss replace boolean
*
* @warning The returned pointer has to be freed by the caller.
*
* @param comments The initial comments, in the form of a JSON formatted character string.
* @param key The key of the key/value pair to add.
* @param value The value of the key/value pair to add.
*
* @returns A pointer on the comments with the added key/value element.
* @retval NULL if an error occurred.
*
* @since August 2018
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
char* obi_add_comment(char* comments, const char* key, const char* value);
#endif /* JSON_UTILS_H_ */