A Fast, Compliant JSON Pull Parser for Writing Robust Applications - Jonathan Müller - CppCon 2023

A fast and compliant JSON pull parser for C++ using range algorithms, designed for robustness, efficiency, and compositability, with optimal performance and memory usage.

Key takeaways
  • C++’s JSON parser has limitations and a high overhead due to coroutines, making writing robust applications challenging.
  • A fast and compliant JSON pull parser can be implemented using range algorithms, which provide better performance and greater control.
  • The parser should not store all JSON data in memory, but instead process it incrementally, allowing for better memory usage and faster processing.
  • The parser should handle errors and edge cases, such as duplicate keys, to ensure robustness.
  • The parser should be designed to be composable, allowing it to be easily extended and modified.
  • Using internal iteration (push model) can be beneficial for performance and efficiency.
  • A custom handler can be created to specific requirements, allowing for more control over the parsing process.
  • Considering lazy evaluation and eager copying are essential for optimizing the parser’s performance and memory usage.
  • The parser should not perform full validation, but instead only validate what is necessary, to improve performance.
  • The parser should be header-only and use range algorithms for better performance.
  • The library implementation should be designed for composable and extensible code.
  • The parser should handle different types of values, such as numbers, strings, arrays, and objects, and be able to determine their types.
  • The parser should be designed to handle edge cases, such as missing values and duplicate keys.
  • The parser should be fast and efficient, but also be able to handle complex scenarios.
  • The parser should provide an optional schema for converting to a specific type.
  • The parser should be able to handle a variety of input data formats, such as JSON and XML.