Code Explainers
Code explainers tagged #json
rust
use serde::Deserialize; #[derive(Debug, Deserialize)] #[serde(untagged)]
Parsing flexible JSON shapes with serde
deserialization
enums
json
Intermediate
6 steps
rust
use axum::{ async_trait, extract::{rejection::JsonRejection, FromRequest, Request}, http::StatusCode,
A validated JSON extractor in Axum
extractors
validation
error-handling
Intermediate
8 steps
php
<?php namespace App\Models;
Storing JSON preferences in a Laravel model
eloquent
casting
json
Intermediate
7 steps
javascript
const express = require('express'); const router = express.Router(); router.get('/exports/orders', async (req, res) => {
Streaming a large JSON export in Express
streaming
backpressure
cursors
Advanced
9 steps
go
package flatten import ( "encoding/json"
Flattening nested JSON into dotted keys
recursion
json
type-switch
Intermediate
7 steps
rust
use serde_json::{Map, Value}; pub fn merge_config(base: &mut Value, override_with: Value) { match (base, override_with) {
Deep-merging JSON config layers in Rust
recursion
json
pattern-matching
Intermediate
9 steps
php
<?php final class TaskProgressReporter {
Tracking task progress in a JSON file
state-persistence
atomic-writes
json
Intermediate
9 steps
ruby
require "base64" require "json" module Attachment
Packing binary attachments into JSON
serialization
base64
json
Intermediate
8 steps
rust
use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct UserProfile {
Trimming JSON output with serde attributes
serialization
json
attributes
Intermediate
8 steps
go
package handlers import ( "encoding/json"
Hardening JSON decoding in Go HTTP handlers
json
error-handling
http
Intermediate
8 steps
go
package api import ( "encoding/json"
Building reusable JSON helpers in Go HTTP handlers
http
json
error-handling
Intermediate
9 steps
rust
use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] #[serde(tag = "type", rename_all = "snake_case")]
Tagged enums with serde in Rust
enums
serialization
json
Intermediate
6 steps
python
from datetime import datetime, date from decimal import Decimal from flask import Flask, jsonify from flask.json.provider import DefaultJSONProvider
Serializing SQLAlchemy models in Flask JSON
serialization
orm
json
Intermediate
6 steps
php
<?php function uploadDocument(string $endpoint, string $filePath, array $meta): array {
Uploading a file with cURL in PHP
curl
file-upload
http
Intermediate
8 steps
python
import json from dataclasses import dataclass, field, asdict from datetime import datetime from typing import Any
JSON round-tripping with Python dataclasses
dataclasses
serialization
json
Intermediate
6 steps
go
package feed import ( "encoding/json"
Streaming a JSON array in Go
streaming
json
decoder
Intermediate
6 steps
java
public class OrderSerializer { private final ObjectMapper mapper;
Configuring a reusable Jackson ObjectMapper
serialization
json
builder-pattern
Intermediate
8 steps
rust
use serde::Deserialize; use serde_json::Value; use std::collections::HashMap;
Modeling nested JSON with serde in Rust
deserialization
json
struct-mapping
Intermediate
9 steps