JsonRemedy.Context.ContextValues (json_remedy v0.1.3)

View Source

Enum definitions and utilities for JSON parsing context values.

This module provides validation, transition logic, and repair prioritization for context values used throughout the JSON repair pipeline.

Summary

Functions

Determines if a transition between contexts is valid.

Determines if a context allows a specific type of repair.

Returns the priority for a repair type in a given context.

Checks if a context value is valid.

Predicts the next expected context based on current context and character.

Returns all valid context values.

Functions

can_transition_to?(from, to)

@spec can_transition_to?(any(), any()) :: boolean()

Determines if a transition between contexts is valid.

Examples

iex> JsonRemedy.Context.ContextValues.can_transition_to?(:root, :object_key)
true

iex> JsonRemedy.Context.ContextValues.can_transition_to?(:root, :object_value)
false

context_allows_repair?(arg1, repair_type)

@spec context_allows_repair?(JsonRemedy.Context.JsonContext.context_value(), atom()) ::
  boolean()

Determines if a context allows a specific type of repair.

Examples

iex> JsonRemedy.Context.ContextValues.context_allows_repair?(:object_key, :unquoted_keys)
true

iex> JsonRemedy.Context.ContextValues.context_allows_repair?(:object_key, :boolean_normalization)
false

get_repair_priority(arg1, repair_type)

Returns the priority for a repair type in a given context.

Higher numbers indicate higher priority.

Examples

iex> JsonRemedy.Context.ContextValues.get_repair_priority(:object_key, :unquoted_keys)
80

iex> JsonRemedy.Context.ContextValues.get_repair_priority(:invalid_context, :quote_normalization)
50

is_valid_context?(context)

@spec is_valid_context?(any()) :: boolean()

Checks if a context value is valid.

Examples

iex> JsonRemedy.Context.ContextValues.is_valid_context?(:object_key)
true

iex> JsonRemedy.Context.ContextValues.is_valid_context?(:invalid)
false

next_expected_context(atom, arg2)

Predicts the next expected context based on current context and character.

Examples

iex> JsonRemedy.Context.ContextValues.next_expected_context(:object_key, ":")
:object_value

iex> JsonRemedy.Context.ContextValues.next_expected_context(:object_value, ",")
:object_key

valid_context_values()

@spec valid_context_values() :: [JsonRemedy.Context.JsonContext.context_value()]

Returns all valid context values.

Examples

iex> JsonRemedy.Context.ContextValues.valid_context_values()
[:root, :object_key, :object_value, :array]