coreJSON v1.0.0
A parser strictly enforcing the ECMA-404 JSON standard, suitable for microcontrollers
core_json.h
Go to the documentation of this file.
1/*
2 * coreJSON v1.0.0
3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22
28#ifndef CORE_JSON_H_
29#define CORE_JSON_H_
30
31#include <stddef.h>
32
37typedef enum
38{
47
81/* @[declare_json_validate] */
82JSONStatus_t JSON_Validate( const char * buf,
83 size_t max );
84/* @[declare_json_validate] */
85
159/* @[declare_json_search] */
160JSONStatus_t JSON_Search( char * buf,
161 size_t max,
162 const char * queryKey,
163 size_t queryKeyLength,
164 char separator,
165 char ** outValue,
166 size_t * outValueLength );
167/* @[declare_json_search] */
168
169#endif /* ifndef CORE_JSON_H_ */
JSONStatus_t JSON_Search(char *buf, size_t max, const char *queryKey, size_t queryKeyLength, char separator, char **outValue, size_t *outValueLength)
Find a key in a JSON object and output the pointer outValue to its value.
Definition: core_json.c:1325
JSONStatus_t JSON_Validate(const char *buf, size_t max)
Parse a buffer to determine if it contains a valid JSON document.
Definition: core_json.c:1094
JSONStatus_t
Return codes from coreJSON library functions.
Definition: core_json.h:38
@ JSONNotFound
Query key could not be found in the JSON document.
Definition: core_json.h:43
@ JSONIllegalDocument
JSON document is invalid or malformed.
Definition: core_json.h:41
@ JSONSuccess
JSON document is valid and complete.
Definition: core_json.h:40
@ JSONBadParameter
Query key is empty, or any subpart is empty, or max is 0.
Definition: core_json.h:45
@ JSONMaxDepthExceeded
JSON document has nesting that exceeds JSON_MAX_DEPTH.
Definition: core_json.h:42
@ JSONNullParameter
Pointer parameter passed to a function is NULL.
Definition: core_json.h:44
@ JSONPartial
JSON document is valid so far but incomplete.
Definition: core_json.h:39