rafagafe / json-maker Goto Github PK
View Code? Open in Web Editor NEWC library used to code JSON objects in null-terminated strings
License: MIT License
C library used to code JSON objects in null-terminated strings
License: MIT License
Hi,
Thanks for publishing this library! I have just been looking at using it in an embedded project, but it seems that when constructing json objects, it is possible to overrun the string buffer without knowing. Perhaps it is worth adding an argument (or a series of โ_sโ suffixed methods) which take an additional length parameter and checks that the length of the string does not increase beyond the allocated buffer length ?
PR #5 introduced an API change that hasn't been reflected onto the tests codebase, resulting in failing build.
Hi! How do I set the output format for double? Example of how this is set for sprintf "%3.6f"
Thanks for the great software!
During integration I found some inconsistencies when adding numbers to the json string.
The remLen variable did not update on the length of the number.
Changing json_num in the following manner seems to fix this:
#define json_num( funcname, type, fmt )
char* funcname( char* dest, char const* name, type value, size_t* remLen ) {
dest = primitivename( dest, name, remLen );
int len = snprintf( dest, *remLen, fmt, value );
dest += len;
*remLen -= len;
dest = chtoa( dest, ',', remLen );
return dest;
}
all the best,
Mike
Does the solidus character needs to be escaped?
Per the rfc https://www.ietf.org/rfc/rfc4627.txt
All Unicode characters may be placed within the
quotation marks except for the characters that must be escaped:
quotation mark, reverse solidus, and the control characters (U+0000
through U+001F).
the solidus doesn't require mandatorily to be escaped. So is it really required ?
prototype in json-maker.h is
char* json_objOpen( char* dest, char const* name, size_t* remLen );
but the sample code is...
dest = json_objOpen( dest, name );
also noticed the code looked suspiciously reactionary to buffer overflow at...
char buff[512];
int len = data_to_json( buff, &data );
if( len >= sizeof buff ) {
fprintf( stderr, "%s%d%s%d\n", "Error. Len: ", len, " Max: ", (int)sizeof buff - 1 );
return EXIT_FAILURE;
}
betting that issue was fixed, but the sample code wasn't updated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.