Results for “Encoding & structured values”
Small, practical examples. Search by task or narrow things down below.
Reject unknown JSON object fields
Reject unknown JSON object fields using a complete Go program with explicit sample inputs.
Go✓ Tested
Remove a known prefix safely
Python: Use removeprefix instead of lstrip when removing a literal prefix rather than a set of characters.
Python✓ Tested
Remove a known suffix safely
Python: Use removesuffix to remove only a matching ending.
Python✓ Tested
Remove a map entry and inspect the number removed
C++: erase by key reports whether a unique-key map contained the entry.
C++✓ Tested
Reorder captured text in a replacement
JavaScript: Use numbered replacement groups to rearrange a known two-part name.
JavaScript✓ Tested
Reorder captured text in a replacement
TypeScript: Use numbered replacement groups to rearrange a known two-part name.
TypeScript✓ Tested
Represent a record with a dataclass
Python: Generate initialization and convert a typed record to a dictionary.
Python✓ Tested
Represent an absent result with optional
C++: value_or supplies a default without requiring a sentinel inside the value domain.
C++✓ Tested
Require every bit in a mask
Arduino / C: Masking followed by equality tests whether all required flags are set.
Arduino / C✓ Tested
Resolve a relative URL against a base
JavaScript: A trailing slash makes the final base path component a directory.
JavaScript✓ Tested
Resolve a relative URL against a base
TypeScript: A trailing slash makes the final base path component a directory.
TypeScript✓ Tested
Return a small immutable named record
Python: Use NamedTuple when callers need both tuple behavior and named fields.
Python✓ Tested