   end
 
   @doc """
+  Closing arrays, when a comma or close array is expected. If it matches, pop that context.
+  """
+  def parse(<<?], t::binary>>, [:comma_or_close_array, :array | context], output) do
+    debug "Closed an array context when a value wasn't expected", t, context, output
+    parse(t, context, output <> <<?]>>)
+  end
+
+  @doc """
   Closing arrays, when a value is not expected. If it matches, pop that context.
   """
   def parse(<<?], t::binary>>, [:array | context], output) do

  alias TheOneTrueJSON, as: JSON

  # just for reference mainly
  @contexts { :string, :number, :decimal, :exponent, :array, :object, :pair, :key, :value, :boolean }
  @whitespace '\s\n\t\r'
  @number_start '-0123456789'
  @digits ?0..?9

  end

  @doc """
  Boolean true, inside an array context. Expect comma or close array.
  """
  def parse(<<?t, ?r, ?u, ?e, t::binary>>, c = [:array | context], output) do
    debug "Matched boolean 'true' inside an array", t, context, output
    parse(t, [:comma_or_close_array | c], output <> "true")
  end

  @doc """
  Boolean false, inside an array context. Expect comma or close array.
  """
  def parse(<<?f, ?a, ?l, ?s, ?e, t::binary>>, c = [:array | context], output) do
    debug "Matched boolean 'false' inside an array", t, context, output
    parse(t, [:comma_or_close_array | c], output <> "false")
  end

  @doc """
  Null, inside an array context. Expect comma or close array.
  """
  def parse(<<?n, ?u, ?l, ?l, t::binary>>, c = [:array | context], output) do
    debug "Matched null/nil inside an array", t, context, output
    parse(t, [:comma_or_close_array | c], output <> "nil")
  end

  @doc """
