commit 4319c5877ae5ca84a2fbd6021416d04dfd348a2b
parent 2f48d0c03380b405da58ccf180820374c87d6f80
Author: Remy Noulin <loader2x@gmail.com>
Date: Tue, 12 Dec 2023 15:35:24 +0200
add jsonMaxValueBufferSize variable to control max value size in json parser
it is needed when parsing a json with a string longer than 1MB
release/json/libsheepyCSmallJson.h | 4 ++++
release/libsheepy.h | 2 +-
src/json/libsheepyCSmallJson.c | 5 +++++
src/json/libsheepyCSmallJson.h | 4 ++++
src/libsheepy.h | 2 +-
5 files changed, 15 insertions(+), 2 deletions(-)
Diffstat:
5 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/release/json/libsheepyCSmallJson.h b/release/json/libsheepyCSmallJson.h
@@ -50,6 +50,10 @@ typedef struct smallJson smallJsont;
// for object inheriting smallJson, cast to smallJson to be able to use this class functions and generics
#define cJs(self) ( (smallJsont*) self )
+// default max value size used in lax_json_create
+// default is 1MB
+extern size_t jsonMaxValueBufferSize;
+
/** json Path Result
* enum type for key type
* NOT_A_PATH is a dictionary key
diff --git a/release/libsheepy.h b/release/libsheepy.h
@@ -98,7 +98,7 @@
// version accoring to the version package: Release.Major.minor.patch
// https://noulin.net/version/file/README.md.html
-#define LIBSHEEPY_VERSION "2.2.13.1"
+#define LIBSHEEPY_VERSION "2.2.14"
#ifndef SH_PREFIX
#define SH_PREFIX(NAME) NAME
diff --git a/src/json/libsheepyCSmallJson.c b/src/json/libsheepyCSmallJson.c
@@ -1698,6 +1698,10 @@ bool writeTextStreamSmallJsonG (smallJsont *self, FILE *fp);
bool appendTextSmallStringSmallJsonG(smallJsont *self, smallStringt *filePath);
bool appendTextJsonSmallJsonG(smallJsont *self, smallJsont *filePath);
+// default max value size used in lax_json_create
+// default is 1MB
+size_t jsonMaxValueBufferSize = 1048576;
+
enum {SMALLJSON_IS_EMPTY, TOP_IS_UNDEFINED, TOP_IS_BOOL, TOP_IS_DOUBLE, TOP_IS_INT, TOP_IS_STRING, TOP_IS_DICT, TOP_IS_ARRAY};
const char *jsonPathResS[] = {"KEY_IS_NULL", "NOT_A_PATH", "ARRAY_PATH", "DICT_PATH", NULL};
@@ -23681,6 +23685,7 @@ internal bool parseSmallJson(smallJsont *self, const char *input) {
context->primitive = on_primitive;
context->begin = on_begin;
context->end = on_end;
+ context->max_value_buffer_size = jsonMaxValueBufferSize;
int err = lax_json_feed(context, (int32_t)jsLen, input);
if (err) {
diff --git a/src/json/libsheepyCSmallJson.h b/src/json/libsheepyCSmallJson.h
@@ -50,6 +50,10 @@ typedef struct smallJson smallJsont;
// for object inheriting smallJson, cast to smallJson to be able to use this class functions and generics
#define cJs(self) ( (smallJsont*) self )
+// default max value size used in lax_json_create
+// default is 1MB
+extern size_t jsonMaxValueBufferSize;
+
/** json Path Result
* enum type for key type
* NOT_A_PATH is a dictionary key
diff --git a/src/libsheepy.h b/src/libsheepy.h
@@ -98,7 +98,7 @@
// version accoring to the version package: Release.Major.minor.patch
// https://noulin.net/version/file/README.md.html
-#define LIBSHEEPY_VERSION "2.2.13.1"
+#define LIBSHEEPY_VERSION "2.2.14"
#ifndef SH_PREFIX
#define SH_PREFIX(NAME) NAME