mirror of
https://github.com/kgabis/parson.git
synced 2024-11-24 06:05:29 +00:00
parent
4158fdbea7
commit
a34e725282
@ -3,7 +3,7 @@ project(parson C)
|
|||||||
|
|
||||||
include (GNUInstallDirs)
|
include (GNUInstallDirs)
|
||||||
|
|
||||||
set(PARSON_VERSION 1.3.1)
|
set(PARSON_VERSION 1.4.0)
|
||||||
add_library(parson parson.c)
|
add_library(parson parson.c)
|
||||||
target_include_directories(parson PUBLIC $<INSTALL_INTERFACE:include>)
|
target_include_directories(parson PUBLIC $<INSTALL_INTERFACE:include>)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "parson",
|
"name": "parson",
|
||||||
"version": "1.3.1",
|
"version": "1.4.0",
|
||||||
"repo": "kgabis/parson",
|
"repo": "kgabis/parson",
|
||||||
"description": "Small json parser and reader",
|
"description": "Small json parser and reader",
|
||||||
"keywords": [ "json", "parser" ],
|
"keywords": [ "json", "parser" ],
|
||||||
|
12
parson.c
12
parson.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
SPDX-License-Identifier: MIT
|
SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
Parson 1.3.1 (https://github.com/kgabis/parson)
|
Parson 1.4.0 (https://github.com/kgabis/parson)
|
||||||
Copyright (c) 2012 - 2022 Krzysztof Gabis
|
Copyright (c) 2012 - 2022 Krzysztof Gabis
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -31,8 +31,8 @@
|
|||||||
#include "parson.h"
|
#include "parson.h"
|
||||||
|
|
||||||
#define PARSON_IMPL_VERSION_MAJOR 1
|
#define PARSON_IMPL_VERSION_MAJOR 1
|
||||||
#define PARSON_IMPL_VERSION_MINOR 3
|
#define PARSON_IMPL_VERSION_MINOR 4
|
||||||
#define PARSON_IMPL_VERSION_PATCH 1
|
#define PARSON_IMPL_VERSION_PATCH 0
|
||||||
|
|
||||||
#if (PARSON_VERSION_MAJOR != PARSON_IMPL_VERSION_MAJOR)\
|
#if (PARSON_VERSION_MAJOR != PARSON_IMPL_VERSION_MAJOR)\
|
||||||
|| (PARSON_VERSION_MINOR != PARSON_IMPL_VERSION_MINOR)\
|
|| (PARSON_VERSION_MINOR != PARSON_IMPL_VERSION_MINOR)\
|
||||||
@ -980,6 +980,9 @@ static JSON_Value * parse_object_value(const char **string, size_t nesting) {
|
|||||||
}
|
}
|
||||||
SKIP_CHAR(string);
|
SKIP_CHAR(string);
|
||||||
SKIP_WHITESPACES(string);
|
SKIP_WHITESPACES(string);
|
||||||
|
if (**string == '}') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SKIP_WHITESPACES(string);
|
SKIP_WHITESPACES(string);
|
||||||
if (**string != '}') {
|
if (**string != '}') {
|
||||||
@ -1025,6 +1028,9 @@ static JSON_Value * parse_array_value(const char **string, size_t nesting) {
|
|||||||
}
|
}
|
||||||
SKIP_CHAR(string);
|
SKIP_CHAR(string);
|
||||||
SKIP_WHITESPACES(string);
|
SKIP_WHITESPACES(string);
|
||||||
|
if (**string == ']') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SKIP_WHITESPACES(string);
|
SKIP_WHITESPACES(string);
|
||||||
if (**string != ']' || /* Trim array after parsing is over */
|
if (**string != ']' || /* Trim array after parsing is over */
|
||||||
|
8
parson.h
8
parson.h
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
SPDX-License-Identifier: MIT
|
SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
Parson 1.3.1 (https://github.com/kgabis/parson)
|
Parson 1.4.0 (https://github.com/kgabis/parson)
|
||||||
Copyright (c) 2012 - 2022 Krzysztof Gabis
|
Copyright (c) 2012 - 2022 Krzysztof Gabis
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -35,10 +35,10 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PARSON_VERSION_MAJOR 1
|
#define PARSON_VERSION_MAJOR 1
|
||||||
#define PARSON_VERSION_MINOR 3
|
#define PARSON_VERSION_MINOR 4
|
||||||
#define PARSON_VERSION_PATCH 1
|
#define PARSON_VERSION_PATCH 0
|
||||||
|
|
||||||
#define PARSON_VERSION_STRING "1.3.1"
|
#define PARSON_VERSION_STRING "1.4.0"
|
||||||
|
|
||||||
#include <stddef.h> /* size_t */
|
#include <stddef.h> /* size_t */
|
||||||
|
|
||||||
|
6
tests.c
6
tests.c
@ -307,6 +307,8 @@ void test_suite_3(void) {
|
|||||||
TEST(json_parse_string("false") != NULL);
|
TEST(json_parse_string("false") != NULL);
|
||||||
TEST(json_parse_string("\"string\"") != NULL);
|
TEST(json_parse_string("\"string\"") != NULL);
|
||||||
TEST(json_parse_string("123") != NULL);
|
TEST(json_parse_string("123") != NULL);
|
||||||
|
TEST(json_parse_string("[\"lorem\",]") != NULL);
|
||||||
|
TEST(json_parse_string("{\"lorem\":\"ipsum\",}") != NULL);
|
||||||
|
|
||||||
/* Test UTF-16 parsing */
|
/* Test UTF-16 parsing */
|
||||||
TEST(STREQ(json_string(json_parse_string("\"\\u0024x\"")), "$x"));
|
TEST(STREQ(json_string(json_parse_string("\"\\u0024x\"")), "$x"));
|
||||||
@ -318,9 +320,9 @@ void test_suite_3(void) {
|
|||||||
g_malloc_count = 0;
|
g_malloc_count = 0;
|
||||||
TEST(json_parse_string(NULL) == NULL);
|
TEST(json_parse_string(NULL) == NULL);
|
||||||
TEST(json_parse_string("") == NULL); /* empty string */
|
TEST(json_parse_string("") == NULL); /* empty string */
|
||||||
TEST(json_parse_string("[\"lorem\",]") == NULL);
|
|
||||||
TEST(json_parse_string("{\"lorem\":\"ipsum\",}") == NULL);
|
|
||||||
TEST(json_parse_string("{lorem:ipsum}") == NULL);
|
TEST(json_parse_string("{lorem:ipsum}") == NULL);
|
||||||
|
TEST(json_parse_string("{\"lorem\":\"ipsum\",]") == NULL);
|
||||||
|
TEST(json_parse_string("{\"lorem\":\"ipsum\",,}") == NULL);
|
||||||
TEST(json_parse_string("[,]") == NULL);
|
TEST(json_parse_string("[,]") == NULL);
|
||||||
TEST(json_parse_string("[,") == NULL);
|
TEST(json_parse_string("[,") == NULL);
|
||||||
TEST(json_parse_string("[") == NULL);
|
TEST(json_parse_string("[") == NULL);
|
||||||
|
@ -31,5 +31,5 @@
|
|||||||
"url" : "https:\/\/www.example.com\/search?q=12345",
|
"url" : "https:\/\/www.example.com\/search?q=12345",
|
||||||
"escaped chars" : "\" \\ \/",
|
"escaped chars" : "\" \\ \/",
|
||||||
"empty object" : {},
|
"empty object" : {},
|
||||||
"empty array" : []
|
"empty array" : [],
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user