systant/server/deps/jason/lib/fragment.ex
ryan b6769abbe9 Restructure as monorepo and add flake packages/apps
- Move Elixir code to server/ subdirectory for monorepo structure
- Update flake.nix to provide packages and apps outputs for nix run support
- Update nix/package.nix to accept src parameter instead of fetchgit
- Add NixOS module export for easy consumption

Now supports: nix run, nix build, and nix develop from git repo

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-02 19:54:17 -07:00

22 lines
604 B
Elixir

defmodule Jason.Fragment do
@moduledoc ~S"""
Provides a way to inject an already-encoded JSON structure into a
to-be-encoded structure in optimized fashion.
This avoids a decoding/encoding round-trip for the subpart.
This feature can be used for caching parts of the JSON, or delegating
the generation of the JSON to a third-party system (e.g. Postgres).
"""
defstruct [:encode]
def new(iodata) when is_list(iodata) or is_binary(iodata) do
%__MODULE__{encode: fn _ -> iodata end}
end
def new(encode) when is_function(encode, 1) do
%__MODULE__{encode: encode}
end
end