Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
fs_json.h File Reference

Detailed Description

Design Philosophy

These functions load and free JSON assets which are compressed and compiled into the filesystem into RAM. Once decompressed and loaded into RAM, the JSON data is a string that may be parsed for whatever purpose.

For information on asset processing, see assets_preprocessor.

Usage

Load JSON files from the filesystem to RAM using loadJson(). JSON strings may be loaded to normal RAM, which is smaller and faster, or SPI RAM, which is larger and slower.

Free when done using freeJson(). If a json is not freed, the memory will leak.

Example

char* jsonStr = loadJson("level_data.json", true);
// Free the json
freeJson(&jsonStr);
void freeJson(char *jsonStr)
Free an allocated JSON string.
Definition fs_json.c:60
char * loadJson(const char *name, bool spiRam)
Load a JSON from ROM to RAM. JSONs placed in the assets_image folder before compilation will be autom...
Definition fs_json.c:37

Go to the source code of this file.

Functions

char * loadJson (const char *name, bool spiRam)
 Load a JSON from ROM to RAM. JSONs placed in the assets_image folder before compilation will be automatically flashed to ROM.
 
void freeJson (char *jsonStr)
 Free an allocated JSON string.
 

Function Documentation

◆ loadJson()

char * loadJson ( const char * name,
bool spiRam )

Load a JSON from ROM to RAM. JSONs placed in the assets_image folder before compilation will be automatically flashed to ROM.

Parameters
nameThe filename of the JSON to load
spiRamtrue to load to SPI RAM, false to load to normal RAM. SPI RAM is more plentiful but slower to access than normal RAM
Returns
A pointer to a null terminated JSON string. May be NULL if the load fails. Must be freed after use

◆ freeJson()

void freeJson ( char * jsonStr)

Free an allocated JSON string.

Parameters
jsonStrthe JSON string to free