d0n3val / stb_json Goto Github PK
View Code? Open in Web Editor NEWSTB-JSON is a header only json parser that aims for a simple interface and integration in the spirit of the STB header only utils
License: Other
STB-JSON is a header only json parser that aims for a simple interface and integration in the spirit of the STB header only utils
License: Other
STB_JSON is a header only json parser that aims for a simple interface and integration in the spirit of the STB header only utils Just include "stb_json.h" in your code and you should be good to go Alternative, a C++ wrapper class is provided "stb_json.hpp" Pros: - Small ( <1K lines code) - Pure C code without any dependency - Does not allocate any memory at all - Simple, just 12 functions Cons: - Not useful for strict parsing - Cannot read exponents in floating point numbers - Cannot read hex in strings - Does not open files or holds memory for you - Does not write json files, only read Example of use: char buffer0[] = "{\"name\": \"John\", \"married\": true, \"height\": 181.55, \"eye colors\": [3,3] }"; stbj_cursor cursor = stbj_load_buffer(buffer0, strlen(buffer0) + 1); if (stbj_any_error(&cursor)) { printf("Error loading JSON buffer %s", stbj_get_last_error(&cursor)); } else { printf("Found %i values at current cursor\n", stbj_count_values(&cursor)); char buf[10]; stbj_read_string_name(&cursor, "name", buf, 10, "not found"); printf("Name: %s\n", buf); if (stbj_read_int_name(&cursor, "married", 0)) printf("... is married\n"); else printf("... is not married\n"); printf("Height is: %0.3f\n", stbj_read_double_name(&cursor, "height", 0.0)); printf("Weight is: %0.3f\n", stbj_read_double_name(&cursor, "weight", 0.0)); // does not exist stbj_cursor cursor_eyes = stbj_move_cursor_name(&cursor, "eye colors"); int left_eye = stbj_read_int_index(&cursor_eyes, 0, -1); int right_eye = stbj_read_int_index(&cursor_eyes, 1, -1); printf("Eyes: %i - %i\n", left_eye, right_eye); } Output: Found 4 values at current cursor Name: John ... is married Height is: 181.550 Weight is: 0.000 Eyes: 3 - 3
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.