grblHAL core  20261015
stream_json.h
Go to the documentation of this file.
1 /*
2  stream_json.h - stream data to file as json structure
3 
4  Part of grblHAL
5 
6  Copyright (c) 2025-2026 Terje Io
7 
8  grblHAL is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  grblHAL is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #include <stdlib.h>
23 #include <stdbool.h>
24 
25 #include "real.h"
26 
27 struct json_out; // members defined in stream_json.c
28 typedef struct json_out json_out_t;
29 typedef bool (*json_callback_ptr)(char *tag, char *value, bool is_string, void *data);
30 
31 json_out_t *json_start (vfs_file_t *file, uint32_t max_levels);
32 bool json_end (json_out_t *json);
33 bool json_start_object (json_out_t *json);
34 bool json_start_tagged_object (json_out_t *json, const char *tag);
35 bool json_end_object (json_out_t *json);
36 bool json_start_array (json_out_t *json, const char *tag);
37 bool json_end_array (json_out_t *json);
38 bool json_add_string (json_out_t *json, const char *tag, const char *s);
39 bool json_add_int (json_out_t *json, const char *tag, int32_t value);
40 bool json_add_real (json_out_t *json, const char *tag, real_t value, uint8_t decimal_places);
41 
42 // a **very** basic json parser, to be improved...
43 bool json_parse_string (char *json, json_callback_ptr callback, void *data);
float real_t
Definition: real.h:48
bool json_start_tagged_object(json_out_t *json, const char *tag)
Definition: stream_json.c:93
bool(* json_callback_ptr)(char *tag, char *value, bool is_string, void *data)
Definition: stream_json.h:29
bool json_start_object(json_out_t *json)
Definition: stream_json.c:78
bool json_start_array(json_out_t *json, const char *tag)
Definition: stream_json.c:114
json_out_t * json_start(vfs_file_t *file, uint32_t max_levels)
Definition: stream_json.c:35
bool json_end_object(json_out_t *json)
Definition: stream_json.c:104
bool json_add_string(json_out_t *json, const char *tag, const char *s)
Definition: stream_json.c:135
bool json_parse_string(char *json, json_callback_ptr callback, void *data)
Definition: stream_json.c:248
bool json_end_array(json_out_t *json)
Definition: stream_json.c:125
bool json_add_real(json_out_t *json, const char *tag, real_t value, uint8_t decimal_places)
Definition: stream_json.c:237
bool json_end(json_out_t *json)
Definition: stream_json.c:48
bool json_add_int(json_out_t *json, const char *tag, int32_t value)
Definition: stream_json.c:223
Definition: stream_json.c:28
vfs_file_t * file
Definition: stream_json.c:29
Definition: vfs.h:95