$ show sile/jsone
jsone is an Erlang library for JSON encoding and decoding that implements RFC7159 compliance. The architecture consists of a main API module (jsone.erl) that delegates to specialized internal modules for decoding (jsone_decode.erl) and encoding (jsone_encode.erl), plus a utility module for IP address handling (jsone_inet.erl). The decoder uses continuation-passing style (CPS) for efficiency, enabling 'creation of sub binary delayed' optimization. The encoder provides extensive customization options including indentation, spacing, float formatting, datetime formatting, and canonical form generation. The library handles UTF-8 encoded binaries, supports multiple Erlang object formats (tuple, proplist, map), and provides both strict and lenient APIs for error handling. It has no external dependencies beyond standard OTP libraries and maintains active CI/CD workflows with regular OTP version testing.
The LLM identified 3 files worth highlighting for reuse:
Implements a highly efficient JSON parser using continuation-passing style (CPS) that facilitates 'creation of sub binary delayed' optimization. The parser handles all JSON grammar elements (objects, arrays, strings, numbers, literals) with proper error handling and stack trace capture. It supports configurable options for object format (tuple/proplist/map), key handling (binary/atom/existing_atom/attempt_atom), UTF-8 validation, and duplicate key resolution. The self-contained design demonstrates non-obvious skill in parser optimization while maintaining readability and correctness.
A highly configurable JSON encoder that supports extensive formatting options including indentation, spacing, float formatting (scientific/decimal/compact), datetime formatting (ISO8601 with timezone handling), canonical form generation, and unknown value mapping. Properly handles UTF-8 encoding, surrogate pairs, and control characters. Implements RFC 5952-compliant IPv6 address formatting when used with the ip_address_to_json_string utility. The encoder demonstrates non-obvious skill in its flexible option handling, edge case management (like NaN/Inf floats via map_unknown_value), and clean separation of concerns between different JSON value types.
Provides RFC 5952-compliant IPv6 address formatting for JSON string conversion. Handles IPv4 addresses and special IPv6 cases (IPv4-compatible, IPv4-mapped, IPv4-translated, and IPv4/IPv6 translated addresses) correctly. The function is completely self-contained with no external dependencies beyond the standard inet:ip_address() type. Demonstrates non-obvious skill in its correct implementation of IPv6 address shortening rules and special case handling, making it a reusable utility for any project requiring standardized IP address representation in JSON.