The powersync-jsonbig package provides a custom JSON parser designed to handle JSON data used throughout the PowerSync ecosystem, including PostgreSQL json/jsonb types, sync query inputs, transformations, and data persistence.
To avoid parsing/serializing overhead and prevent data mutation, JSON data is often kept as strings. The custom parser specifically addresses the following requirements:
- Preserving SQLite Type Distinctions: It maintains the distinction between
INTEGER and REAL values as defined by the SQLite type system. - Handling 64-bit Integers: It uses
BigInt for all integer values to support the 64-bit integer range available in SQLite, preventing precision loss that occurs with standard JavaScript numbers.