diff options
author | rafa_99 <raroma09@gmail.com> | 2021-08-31 21:35:15 +0100 |
---|---|---|
committer | rafa_99 <raroma09@gmail.com> | 2021-08-31 21:35:15 +0100 |
commit | dae23472f41380b232134d20412d59844040daea (patch) | |
tree | 8f57755b6bc90777e3fa4c1acae9efdaa3ecb87f | |
parent | 3b9a6fd52393f7509b9c575ed5e6dbc37c43b653 (diff) |
Started Working on JSON parsing
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | libs/json.c | 13 | ||||
-rw-r--r-- | libs/json.h | 4 |
3 files changed, 23 insertions, 3 deletions
@@ -2,17 +2,20 @@ # See LICENSE file for copyright and license details. # Source Code -SRC = queryt.c utils.c libs/curl.c libs/string.c video.c +SRC = queryt.c utils.c video.c libs/curl.c libs/string.c libs/json.c + +# Libraries +LIBS = -lcurl -ljson-c # Compiled Code CLEAN = queryt # MakeOPTS build: clean - cc -o queryt ${SRC} -lcurl + cc -o queryt ${SRC} ${LIBS} debug: clean - cc -g -o queryt ${SRC} -lcurl + cc -g -o queryt ${SRC} ${LIBS} clean: rm -rf ${CLEAN} diff --git a/libs/json.c b/libs/json.c new file mode 100644 index 0000000..4b0dac0 --- /dev/null +++ b/libs/json.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <json-c/json.h> +#include "json.h" + +json_object* jsonParseString(char* stringedJSON) +{ + struct json_object *json; + json = ( stringedJSON != NULL && strlen(stringedJSON) > 0 ) ? json_tokener_parse(stringedJSON) : NULL; + free(stringedJSON); + return json; +} diff --git a/libs/json.h b/libs/json.h new file mode 100644 index 0000000..3896805 --- /dev/null +++ b/libs/json.h @@ -0,0 +1,4 @@ +#pragma once +#include <json-c/json.h> + +json_object* jsonParseString(char* stringedJSON); |