garrisonhh / ghh_json Goto Github PK
View Code? Open in Web Editor NEWsingle-header, programmer-friendly json library for C99 and C++
single-header, programmer-friendly json library for C99 and C++
Hi,
Thank you for your great and useful json parser! It's super easy to use.
I've got an error when trying to parse a json object with an empty array. Example:
json_t json2;
char *test = "{\"foo\":\"bar\",\"boo\":[]}";
json_load(&json2, test);
Error:
JSON ERROR: unknown token, expected value.
1 | {"foo":"bar","boo":[]}
|
Kind regards,
Is there an easy way to merge two JSON objects? E.g. if they have the same keys then overwrite, otherwise add new?
Thanks,
Bartek
Hi,
Thanks for this great library! I noticed that non-scientific floating point numbers are not supported, i.e. they are parsed into completely wrong numbers which was hard to debug :)
E.g. this works: 1e-3 but this doesn't: 0.001, it actually outputs 0.1.
I propose to simplify json_expect_number
to this code:
#include <stdlib.h>. // for strtod
...
static double json_expect_number(json_ctx_t *ctx) {
// Convert string to double
double num = strtod(&ctx->text[ctx->index], NULL);
// Move pointer until not a comma and not end of line
while (ctx->text[ctx->index] != ',' && ctx->text[ctx->index] != '\n' && ctx->text[ctx->index] != ']') {
ctx->index++;
}
return num;
}
Works well this way with both scientific and regular notation.
Cheers,
Bartek
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.