JSON Guides
Practical, copy-ready guides for reading and writing JSON in every major language — parse, stringify, pretty-print and handle errors the idiomatic way.
Parse JSON in JavaScript
Parse and stringify JSON in JavaScript with JSON.parse and JSON.stringify. Pretty-print, handle errors, use reviver/replacer, and avoid common pitfalls.
Parse JSON in Python
Parse and write JSON in Python with the json module: json.loads, json.dumps, json.load and json.dump. Pretty-print, sort keys, and handle JSONDecodeError.
Parse JSON in Go
Parse and encode JSON in Go with encoding/json: json.Unmarshal, json.Marshal, MarshalIndent, struct tags, and decoding into maps or structs.
Parse JSON in Java
Parse JSON in Java with Jackson (ObjectMapper) or org.json. Deserialize to POJOs, read trees, and pretty-print with writerWithDefaultPrettyPrinter.
Parse JSON in C#
Parse JSON in C# with System.Text.Json: JsonSerializer.Deserialize, Serialize, JsonDocument, and pretty-print with WriteIndented. Newtonsoft alternative included.
Parse JSON in PHP
Parse JSON in PHP with json_decode and json_encode. Decode to arrays or objects, pretty-print with JSON_PRETTY_PRINT, and check errors with json_last_error.
Parse JSON in Ruby
Parse JSON in Ruby with the json library: JSON.parse, JSON.generate, and JSON.pretty_generate. Symbolize keys and handle JSON::ParserError.
Parse JSON in Rust
Parse JSON in Rust with serde_json: from_str into typed structs with derive(Deserialize), the untyped Value type, and to_string_pretty for output.
Parse JSON in TypeScript
Parse JSON in TypeScript with JSON.parse, add type safety with interfaces and generics, and validate at runtime with Zod. Avoid the any pitfall.
Parse JSON in Kotlin
Parse JSON in Kotlin with kotlinx.serialization: @Serializable data classes, Json.decodeFromString, encodeToString, and pretty-print. Gson alternative noted.
Parse JSON in Swift
Parse JSON in Swift with Codable, JSONDecoder and JSONEncoder. Decode into structs, handle snake_case keys, pretty-print, and catch DecodingError.
Parse JSON in C++
Parse JSON in C++ with the nlohmann/json library: parse strings, access values, convert to structs, serialize, and pretty-print with dump(2).
Parse JSON in Bash (jq)
Parse JSON on the command line with jq: extract fields, filter arrays, map values, and pretty-print. Handle API responses in shell scripts.
Parse JSON in PowerShell
Parse JSON in PowerShell with ConvertFrom-Json and ConvertTo-Json. Access properties, read from files and APIs, and control depth and formatting.