|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: C SDK |
| 4 | +--- |
| 5 | + |
| 6 | +# C SDK |
| 7 | + |
| 8 | +The official JSON Structure SDK for C (and C++). |
| 9 | + |
| 10 | +## Installation |
| 11 | + |
| 12 | +### vcpkg |
| 13 | + |
| 14 | +```bash |
| 15 | +vcpkg install json-structure |
| 16 | +``` |
| 17 | + |
| 18 | +### CMake FetchContent |
| 19 | + |
| 20 | +```cmake |
| 21 | +include(FetchContent) |
| 22 | +FetchContent_Declare( |
| 23 | + json-structure |
| 24 | + GIT_REPOSITORY https://github.com/json-structure/sdk.git |
| 25 | + GIT_TAG v0.5.3 |
| 26 | + SOURCE_SUBDIR c |
| 27 | +) |
| 28 | +FetchContent_MakeAvailable(json-structure) |
| 29 | +
|
| 30 | +target_link_libraries(your_target PRIVATE json-structure) |
| 31 | +``` |
| 32 | + |
| 33 | +## Package Links |
| 34 | + |
| 35 | +- **vcpkg**: [json-structure](https://vcpkg.io/en/package/json-structure) |
| 36 | +- **GitHub**: [json-structure/sdk/c](https://github.com/json-structure/sdk/tree/master/c) |
| 37 | + |
| 38 | +## Usage |
| 39 | + |
| 40 | +```c |
| 41 | +#include <json_structure.h> |
| 42 | + |
| 43 | +int main() { |
| 44 | + // Validate a schema |
| 45 | + js_schema_validator_t* schema_validator = js_schema_validator_new(); |
| 46 | + js_validation_result_t* schema_result = js_schema_validator_validate(schema_validator, schema); |
| 47 | + |
| 48 | + // Validate an instance against a schema |
| 49 | + js_instance_validator_t* instance_validator = js_instance_validator_new(); |
| 50 | + js_validation_result_t* instance_result = js_instance_validator_validate(instance_validator, instance, schema); |
| 51 | + |
| 52 | + // Cleanup |
| 53 | + js_validation_result_free(schema_result); |
| 54 | + js_validation_result_free(instance_result); |
| 55 | + js_schema_validator_free(schema_validator); |
| 56 | + js_instance_validator_free(instance_validator); |
| 57 | + |
| 58 | + return 0; |
| 59 | +} |
| 60 | +``` |
| 61 | + |
| 62 | +## Features |
| 63 | + |
| 64 | +- Schema validation against JSON Structure meta-schemas |
| 65 | +- Instance validation against JSON Structure schemas |
| 66 | +- C11 standard |
| 67 | +- Cross-platform (Windows, Linux, macOS) |
| 68 | +- Uses cJSON for JSON parsing |
| 69 | + |
| 70 | +## Documentation |
| 71 | + |
| 72 | +See the [README](https://github.com/json-structure/sdk/tree/master/c#readme) for full documentation. |
0 commit comments