JsonRemedy.Context.ContextValues (json_remedy v0.1.3)
View SourceEnum 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
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
@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
@spec get_repair_priority(JsonRemedy.Context.JsonContext.context_value(), atom()) :: non_neg_integer()
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
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
@spec next_expected_context( JsonRemedy.Context.JsonContext.context_value(), String.t() ) :: JsonRemedy.Context.JsonContext.context_value() | :pop_context
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
@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]