mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
981f59b163 | ||
|
|
e4eadb9a81 | ||
|
|
ff0681e4fd | ||
|
|
a2309a509d | ||
|
|
c49ffbfba8 | ||
|
|
e7533aa6f0 |
@@ -7,7 +7,7 @@ project(cJSON C)
|
|||||||
|
|
||||||
set(PROJECT_VERSION_MAJOR 1)
|
set(PROJECT_VERSION_MAJOR 1)
|
||||||
set(PROJECT_VERSION_MINOR 2)
|
set(PROJECT_VERSION_MINOR 2)
|
||||||
set(PROJECT_VERSION_PATCH 0)
|
set(PROJECT_VERSION_PATCH 1)
|
||||||
set(CJSON_VERSION_SO 1)
|
set(CJSON_VERSION_SO 1)
|
||||||
set(CJSON_UTILS_VERSION_SO 1)
|
set(CJSON_UTILS_VERSION_SO 1)
|
||||||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -10,7 +10,7 @@ UTILS_TEST_SRC = cJSON.c cJSON_Utils.c test_utils.c
|
|||||||
|
|
||||||
LDLIBS = -lm
|
LDLIBS = -lm
|
||||||
|
|
||||||
LIBVERSION = 1.2.0
|
LIBVERSION = 1.2.1
|
||||||
CJSON_SOVERSION = 1
|
CJSON_SOVERSION = 1
|
||||||
UTILS_SOVERSION = 1
|
UTILS_SOVERSION = 1
|
||||||
|
|
||||||
|
|||||||
8
cJSON.c
8
cJSON.c
@@ -58,6 +58,14 @@ const char *cJSON_GetErrorPtr(void)
|
|||||||
return global_ep;
|
return global_ep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern const char* cJSON_Version(void)
|
||||||
|
{
|
||||||
|
static char version[15];
|
||||||
|
sprintf(version, "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH);
|
||||||
|
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
/* case insensitive strcmp */
|
/* case insensitive strcmp */
|
||||||
static int cJSON_strcasecmp(const char *s1, const char *s2)
|
static int cJSON_strcasecmp(const char *s1, const char *s2)
|
||||||
{
|
{
|
||||||
|
|||||||
8
cJSON.h
8
cJSON.h
@@ -28,6 +28,14 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* project version */
|
||||||
|
#define CJSON_VERSION_MAJOR 1
|
||||||
|
#define CJSON_VERSION_MINOR 2
|
||||||
|
#define CJSON_VERSION_PATCH 1
|
||||||
|
|
||||||
|
/* returns the version of cJSON as a string */
|
||||||
|
extern const char* cJSON_Version(void);
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
/* cJSON Types: */
|
/* cJSON Types: */
|
||||||
|
|||||||
@@ -208,6 +208,11 @@ cJSON *cJSONUtils_GetPointer(cJSON *object, const char *pointer)
|
|||||||
static void cJSONUtils_InplaceDecodePointerString(char *string)
|
static void cJSONUtils_InplaceDecodePointerString(char *string)
|
||||||
{
|
{
|
||||||
char *s2 = string;
|
char *s2 = string;
|
||||||
|
|
||||||
|
if (string == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (; *string; s2++, string++)
|
for (; *string; s2++, string++)
|
||||||
{
|
{
|
||||||
*s2 = (*string != '~')
|
*s2 = (*string != '~')
|
||||||
@@ -229,12 +234,19 @@ static cJSON *cJSONUtils_PatchDetach(cJSON *object, const char *path)
|
|||||||
|
|
||||||
/* copy path and split it in parent and child */
|
/* copy path and split it in parent and child */
|
||||||
parentptr = cJSONUtils_strdup(path);
|
parentptr = cJSONUtils_strdup(path);
|
||||||
childptr = strrchr(parentptr, '/'); /* last '/' */
|
if (parentptr == NULL) {
|
||||||
if (childptr)
|
return NULL;
|
||||||
{
|
|
||||||
/* split strings */
|
|
||||||
*childptr++ = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
childptr = strrchr(parentptr, '/'); /* last '/' */
|
||||||
|
if (childptr == NULL)
|
||||||
|
{
|
||||||
|
free(parentptr);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* split strings */
|
||||||
|
*childptr++ = '\0';
|
||||||
|
|
||||||
parent = cJSONUtils_GetPointer(object, parentptr);
|
parent = cJSONUtils_GetPointer(object, parentptr);
|
||||||
cJSONUtils_InplaceDecodePointerString(childptr);
|
cJSONUtils_InplaceDecodePointerString(childptr);
|
||||||
|
|
||||||
|
|||||||
3
test.c
3
test.c
@@ -382,6 +382,9 @@ int main(void)
|
|||||||
"</body>\n"
|
"</body>\n"
|
||||||
"</html>\n";
|
"</html>\n";
|
||||||
|
|
||||||
|
/* print the version */
|
||||||
|
printf("Version: %s\n", cJSON_Version());
|
||||||
|
|
||||||
/* Process each json textblock by parsing, then rebuilding: */
|
/* Process each json textblock by parsing, then rebuilding: */
|
||||||
doit(text1);
|
doit(text1);
|
||||||
doit(text2);
|
doit(text2);
|
||||||
|
|||||||
Reference in New Issue
Block a user