#json Clear
Tags #php #kotlin #bash #go #sql #rust #typescript #html #java #python #files #utils #strings #http #concurrency #async #json #arrays #security #types #crypto #database #dates #format
Go JSON Marshal / Unmarshal
`encoding/json` is the standard library JSON parser. `Marshal` produces compact JSON; `MarshalIndent` produces pretty-printed. `Unmarshal` decodes into a typed value (struct, map, or any).
Bash Extract JSON Field with jq
jq is the de-facto JSON tool. Pipe any JSON in, get a parsed/filtered/reshaped result out. Indispensable in deploy scripts that consume API output.
Bash Pretty-Print JSON from cURL
Pipe API responses through jq for syntax-colored, indented output. Also great for extracting specific fields without writing a parser.
Go JSON API Endpoint
Decode an incoming JSON body into a typed struct, do work, encode a JSON response. The whole roundtrip is ~20 lines of standard library.
Kotlin Ktor Server — JSON API with kotlinx.serialization
Install `ContentNegotiation` + `Json` plugin and you get typed (de)serialization for every route. Decode request bodies into data classes; respond with data classes.
Java Jackson — Basic ObjectMapper
`com.fasterxml.jackson.databind.ObjectMapper` is the JSON standard for Java. Construct once (it's expensive + thread-safe) and reuse for every serialization in your app.
Java Jackson — Annotations (rename, ignore, etc)
Field-level annotations let you map between snake_case JSON and camelCase Java, skip nulls, never serialize secrets, set defaults on missing fields.
Kotlin kotlinx.serialization — JSON Basics
Compile-time code generation for JSON serialization. Annotate `@Serializable` on a data class; `Json.encodeToString` and `Json.decodeFromString` are typed.
SQL JSONB Columns (PostgreSQL)
`jsonb` stores binary-optimized JSON. Index sub-fields with GIN for fast containment queries. Most-used operators: `->` (get field), `->>` (get as text), `@>` (contains), `?` (key exists).
PHP JSON Structured Logger
Append a single JSON object per line to a log file. Easy to grep and to ship into Datadog / Loki / CloudWatch later without re-parsing.
Rust reqwest GET + JSON Deserialize
`reqwest` is the standard HTTP client. Combined with serde, you can fetch and parse a JSON API response into a typed struct in three lines.
Java HttpClient — POST JSON
POST a JSON body with `HttpRequest.BodyPublishers.ofString` + the right Content-Type. Pair with Jackson / Gson to serialize objects to JSON.
Rust reqwest POST JSON
Send a JSON body by calling `.json(&value)` — serde handles serialization. Read the response body or status code afterwards.
PHP cURL POST JSON
Post a JSON body with the right Content-Type header and parse the response. Returns the decoded body or throws on a non-2xx response.
Kotlin Ktor Client — POST JSON with Serialization
Combine Ktor + kotlinx.serialization: register the JSON plugin, declare `@Serializable` data classes, the client (de)serializes automatically.
TypeScript JSON POST Helper
Companion to `http<T>` — POST a JSON body and parse a JSON response, both typed. Handles the boilerplate Content-Type header and JSON serialization.
Go HTTP POST JSON Body
Build a request with `http.NewRequestWithContext`, set headers, send via your client. The context plumbing is what lets callers cancel mid-request.
PHP JSON Lines (NDJSON) Stream Reader
Read newline-delimited JSON (one object per line) as a generator. Each yield gives you the next decoded record without holding the whole file in memory.