JsonRemedy.Combinators (json_remedy v0.1.0)

View Source

Parser combinator-based JSON repair using NimbleParsec.

This approach builds JSON parsing from small, composable functions that can each handle and repair specific syntax issues. While more elegant than direct parsing, it's currently a placeholder for future implementation.

Summary

Functions

Repairs JSON using parser combinator approach.

Types

repair_result()

@type repair_result() ::
  {:ok, term()} | {:ok, term(), [String.t()]} | {:error, String.t()}

Functions

repair(json_string, opts)

@spec repair(
  binary(),
  keyword()
) :: repair_result()

Repairs JSON using parser combinator approach.

Currently delegates to BinaryParser but will be implemented as a proper combinator-based parser in Phase 2.

Parameters

  • json_string: The malformed JSON string to repair
  • opts: Keyword list of options

Returns

  • {:ok, term()} if repair succeeds without logging
  • {:ok, term(), [String.t()]} if repair succeeds with logging enabled
  • {:error, String.t()} if repair fails

Examples

iex> JsonRemedy.Combinators.repair(~s|{name: "Alice"}|, [])
{:ok, %{"name" => "Alice"}}