1650016800
Very low footprint JSON parser written in portable C89 (sometimes referred to as ANSI C).
Want to serialize? Check out json-builder!
There is now a makefile which will produce a libjsonparser static and dynamic library. However, this is not required to build json-parser, and the source files (json.c
and json.h
) should be happy in any build system you already have in place.
json_value * json_parse (const json_char * json,
size_t length);
json_value * json_parse_ex (json_settings * settings,
const json_char * json,
size_t length,
char * error);
void json_value_free (json_value *);
The type
field of json_value
is one of:
json_object
(see u.object.length
, u.object.values[x].name
, u.object.values[x].value
)json_array
(see u.array.length
, u.array.values
)json_integer
(see u.integer
)json_double
(see u.dbl
)json_string
(see u.string.ptr
, u.string.length
)json_boolean
(see u.boolean
)json_null
Unless otherwise specified, compile definitions must be provided both when compiling json.c
and when compiling any of your own source files that include json.h
.
JSON_TRACK_SOURCE
Stores the source location (line and column number) inside each json_value
.
This is useful for application-level error reporting.
json_int_t
By default, json_int_t
is defined as long
under C89 and int_fast64_t
otherwise. For MSVC it is defined as __int64
regardless of language standard support.
Optionally, you may define json_int_t
to be your own preferred type name for integer types parsed from JSON documents. It must be a signed integer type, there is no support for unsigned types. If you specify a raw primitive type without signed
or unsigned
(and not a typdef), JSON_INT_MAX
will be calculated for you. Otherwise, you must provide your own definition of JSON_INT_MAX
as the highest positive integer value that can be represented by json_int_t
.
Example usage:
-Djson_int_t=short
"-Djson_int_t=signed char" -DJSON_INT_MAX=127
"-Djson_int_t=long long"
-Djson_int_t=__int128
settings |= json_enable_comments;
Enables C-style // line
and /* block */
comments.
size_t value_extra
The amount of space (if any) to allocate at the end of each json_value
, in order to give the application space to add metadata.
void * (* mem_alloc) (size_t, int zero, void * user_data);
void (* mem_free) (void *, void * user_data);
Custom allocator routines. If NULL, the default malloc
and free
will be used.
The user_data
pointer will be forwarded from json_settings
to allow application context to be passed.
UTF-8 byte order marks are now skipped if present
Allows cross-compilation by honoring --host if given (@wkz)
Maximum size for error buffer is now exposed in header (@LB--)
GCC warning for static
after const
fixed (@batrick)
Optional support for C-style line and block comments added (@Jin-W-FS)
name_length
field added to object values
It is now possible to retrieve the source line/column number of a parsed json_value
when JSON_TRACK_SOURCE
is enabled
The application may now extend json_value
using the value_extra
setting
Un-ambiguate pow call in the case of C++ overloaded pow (@fcartegnie)
Fix null pointer de-reference when a non-existing array is closed and no root value is present
Author: json-parser
Source Code: https://github.com/json-parser/json-parser
License: BSD-2-Clause License
1650016800
Very low footprint JSON parser written in portable C89 (sometimes referred to as ANSI C).
Want to serialize? Check out json-builder!
There is now a makefile which will produce a libjsonparser static and dynamic library. However, this is not required to build json-parser, and the source files (json.c
and json.h
) should be happy in any build system you already have in place.
json_value * json_parse (const json_char * json,
size_t length);
json_value * json_parse_ex (json_settings * settings,
const json_char * json,
size_t length,
char * error);
void json_value_free (json_value *);
The type
field of json_value
is one of:
json_object
(see u.object.length
, u.object.values[x].name
, u.object.values[x].value
)json_array
(see u.array.length
, u.array.values
)json_integer
(see u.integer
)json_double
(see u.dbl
)json_string
(see u.string.ptr
, u.string.length
)json_boolean
(see u.boolean
)json_null
Unless otherwise specified, compile definitions must be provided both when compiling json.c
and when compiling any of your own source files that include json.h
.
JSON_TRACK_SOURCE
Stores the source location (line and column number) inside each json_value
.
This is useful for application-level error reporting.
json_int_t
By default, json_int_t
is defined as long
under C89 and int_fast64_t
otherwise. For MSVC it is defined as __int64
regardless of language standard support.
Optionally, you may define json_int_t
to be your own preferred type name for integer types parsed from JSON documents. It must be a signed integer type, there is no support for unsigned types. If you specify a raw primitive type without signed
or unsigned
(and not a typdef), JSON_INT_MAX
will be calculated for you. Otherwise, you must provide your own definition of JSON_INT_MAX
as the highest positive integer value that can be represented by json_int_t
.
Example usage:
-Djson_int_t=short
"-Djson_int_t=signed char" -DJSON_INT_MAX=127
"-Djson_int_t=long long"
-Djson_int_t=__int128
settings |= json_enable_comments;
Enables C-style // line
and /* block */
comments.
size_t value_extra
The amount of space (if any) to allocate at the end of each json_value
, in order to give the application space to add metadata.
void * (* mem_alloc) (size_t, int zero, void * user_data);
void (* mem_free) (void *, void * user_data);
Custom allocator routines. If NULL, the default malloc
and free
will be used.
The user_data
pointer will be forwarded from json_settings
to allow application context to be passed.
UTF-8 byte order marks are now skipped if present
Allows cross-compilation by honoring --host if given (@wkz)
Maximum size for error buffer is now exposed in header (@LB--)
GCC warning for static
after const
fixed (@batrick)
Optional support for C-style line and block comments added (@Jin-W-FS)
name_length
field added to object values
It is now possible to retrieve the source line/column number of a parsed json_value
when JSON_TRACK_SOURCE
is enabled
The application may now extend json_value
using the value_extra
setting
Un-ambiguate pow call in the case of C++ overloaded pow (@fcartegnie)
Fix null pointer de-reference when a non-existing array is closed and no root value is present
Author: json-parser
Source Code: https://github.com/json-parser/json-parser
License: BSD-2-Clause License
1625637060
In this video, we work with JSONs, which are a common data format for most web services (i.e. APIs). Thank you for watching and happy coding!
Need some new tech gadgets or a new charger? Buy from my Amazon Storefront https://www.amazon.com/shop/blondiebytes
What is an API?
https://youtu.be/T74OdSCBJfw
JSON Google Extension
https://chrome.google.com/webstore/detail/json-formatter/bcjindcccaagfpapjjmafapmmgkkhgoa?hl=en
Endpoint Example
http://maps.googleapis.com/maps/api/geocode/json?address=13+East+60th+Street+New+York,+NY
Check out my courses on LinkedIn Learning!
REFERRAL CODE: https://linkedin-learning.pxf.io/blondiebytes
https://www.linkedin.com/learning/instructors/kathryn-hodge
Support me on Patreon!
https://www.patreon.com/blondiebytes
Check out my Python Basics course on Highbrow!
https://gohighbrow.com/portfolio/python-basics/
Check out behind-the-scenes and more tech tips on my Instagram!
https://instagram.com/blondiebytes/
Free HACKATHON MODE playlist:
https://open.spotify.com/user/12124758083/playlist/6cuse5033woPHT2wf9NdDa?si=VFe9mYuGSP6SUoj8JBYuwg
MY FAVORITE THINGS:
Stitch Fix Invite Code: https://www.stitchfix.com/referral/10013108?sod=w&som=c
FabFitFun Invite Code: http://xo.fff.me/h9-GH
Uber Invite Code: kathrynh1277ue
Postmates Invite Code: 7373F
SoulCycle Invite Code: https://www.soul-cycle.com/r/WY3DlxF0/
Rent The Runway: https://rtr.app.link/e/rfHlXRUZuO
Want to BINGE?? Check out these playlists…
Quick Code Tutorials: https://www.youtube.com/watch?v=4K4QhIAfGKY&index=1&list=PLcLMSci1ZoPu9ryGJvDDuunVMjwKhDpkB
Command Line: https://www.youtube.com/watch?v=Jm8-UFf8IMg&index=1&list=PLcLMSci1ZoPvbvAIn_tuSzMgF1c7VVJ6e
30 Days of Code: https://www.youtube.com/watch?v=K5WxmFfIWbo&index=2&list=PLcLMSci1ZoPs6jV0O3LBJwChjRon3lE1F
Intermediate Web Dev Tutorials: https://www.youtube.com/watch?v=LFa9fnQGb3g&index=1&list=PLcLMSci1ZoPubx8doMzttR2ROIl4uzQbK
GitHub | https://github.com/blondiebytes
Twitter | https://twitter.com/blondiebytes
LinkedIn | https://www.linkedin.com/in/blondiebytes
#jsons #json arrays #json objects #what is json #jsons tutorial #blondiebytes
1624240146
C and C++ are the most powerful programming language in the world. Most of the super fast and complex libraries and algorithms are written in C or C++. Most powerful Kernel programs are also written in C. So, there is no way to skip it.
In programming competitions, most programmers prefer to write code in C or C++. Tourist is considered the worlds top programming contestant of all ages who write code in C++.
During programming competitions, programmers prefer to use a lightweight editor to focus on coding and algorithm designing. Vim, Sublime Text, and Notepad++ are the most common editors for us. Apart from the competition, many software developers and professionals love to use Sublime Text just because of its flexibility.
I have discussed the steps we need to complete in this blog post before running a C/C++ code in Sublime Text. We will take the inputs from an input file and print outputs to an output file without using freopen
file related functions in C/C++.
#cpp #c #c-programming #sublimetext #c++ #c/c++
1597937354
If you are familiar with C/C++then you must have come across some unusual things and if you haven’t, then you are about to. The below codes are checked twice before adding, so feel free to share this article with your friends. The following displays some of the issues:
The below code generates no error since a print function can take any number of inputs but creates a mismatch with the variables. The print function is used to display characters, strings, integers, float, octal, and hexadecimal values onto the output screen. The format specifier is used to display the value of a variable.
A signed integer is a 32-bit datum that encodes an integer in the range [-2147483648 to 2147483647]. An unsigned integer is a 32-bit datum that encodes a non-negative integer in the range [0 to 4294967295]. The signed integer is represented in twos-complement notation. In the below code the signed integer will be converted to the maximum unsigned integer then compared with the unsigned integer.
#problems-with-c #dicey-issues-in-c #c-programming #c++ #c #cplusplus
1589816580
In this article, we’ll take a look at using the isdigit() function in C/C++. This is a very simple way to check if any value is a digit or not. Let’s look at how to use this function, using some simple examples.
#c programming #c++ #c #c#