#json
18 snippets tagged with #json
Read and Write JSON Files
Read, parse, modify, and write JSON files with proper error handling using Node.js fs module.
Best for: Configuration file management
JSON Stream Parser
Parses large JSON arrays from a readable stream without loading the entire file into memory.
Best for: Processing large log files
JSON Aggregation and Querying
Aggregate related rows into JSON arrays and query JSONB columns with PostgreSQL native JSON operators.
Best for: API response building
Query JSON Columns in SQL
Extract and filter data stored in JSON columns using SQL JSON functions.
Best for: Querying semi-structured data
JSON - Technique 12
Work with JSON data
Best for: database operations
Structured Logging with structlog
Configure structlog for JSON-formatted structured logging with request context, timestamps, and log levels.
Best for: Application logging
OpenAI Structured Output with Zod
Force GPT-4o to return valid JSON matching a Zod schema using response_format structured output.
Best for: data extraction
OpenAI Structured Output with Pydantic
Force GPT to return validated JSON matching a Pydantic schema.
Best for: Review analysis
Nested JSON Flattening in Python
Flatten deeply nested JSON structures into flat dictionaries suitable for DataFrames or CSV export.
Best for: Converting API responses to flat tables
Flatten Nested JSON with pandas
Use pd.json_normalize to flatten deeply nested API responses into a flat DataFrame.
Best for: API response flattening
Fast JSON Serialisation with orjson
Use orjson for 5-10x faster JSON serialisation of large Python dicts, dataclasses, and NumPy arrays.
Best for: high-throughput serialisation
DataFrame to Dict Records
Convert DataFrames to lists of dicts for API responses, JSON export, or further processing.
Best for: API serialization
Expand JSON Column into DataFrame Columns
Parse a JSON-string column and expand its keys into separate columns in one step.
Best for: JSON column expansion
Jackson — JSON Serialization and Parsing
Parse and generate JSON with Jackson: ObjectMapper, annotations, custom serializers, and streaming.
Best for: REST API request and response serialization
JSON Serialization Without Libraries
Serialize and deserialize Java objects to JSON manually with a lightweight builder-based approach.
Best for: Lightweight JSON generation without Jackson/Gson
Kotlinx Serialization — JSON Parsing
Serialize and deserialize JSON with kotlinx.serialization: data classes, custom serializers, and polymorphism.
Best for: API response parsing and generation
JSON Parsing with Circe
Parse and generate JSON with Circe: codecs, custom encoders/decoders, and optics.
Best for: REST API JSON handling
Advanced JSON with Circe
Handle complex JSON with Circe: custom codecs, optics, cursor navigation, and error handling.
Best for: API response parsing