Skip to content

Honor constructor symbolize_names when decoding JSON - #46

Open
yorzi wants to merge 1 commit into
serpapi:masterfrom
yorzi:fix/constructor-symbolize-names
Open

yorzi wants to merge 1 commit into
serpapi:masterfrom
yorzi:fix/constructor-symbolize-names

Conversation

@yorzi

@yorzi yorzi commented Nov 17, 2026

Copy link
Copy Markdown

What this does

Read the parser option with precedence: per-call, constructor, then true.
Previously the documented constructor setting was ignored. This is one
production-line change plus a changelog entry and 16 focused examples.
It follows the existing Hash#fetch parser implementation.

Five examples fail on the base: constructor false for search in both
connection modes, archive, account, and upload. The other examples guard
defaults, explicit overrides, text output, and parser-option stripping
from GET query and POST form fields.

No public method or dependency is added. Error-policy fixes remain in
#42; Hash mutation remains
in #39. Closed
#22 is prior work.
The current patches for #39 and #42 apply alongside this change.

Merge order: error detection reads Symbol keys only, so on master
alone, clients that set false in the constructor inherit the existing
per-call false gap (a 200 with error is returned, not raised).
#42 closes that gap. With #42 applied, constructor false matches the
default for empty results, status: "Error", and 401. Please merge
this after #42, or tell me if you prefer a different order.

No live fixture needs re-recording because requests are unchanged.
The constructor already documents this option, so no README change is
needed. The new spec stubs the HTTP transport, like image_api_spec.rb.

Type of change

  • Bug fix
  • New feature (not applicable)
  • Breaking change (restores the documented option)
  • Documentation (existing option documentation is unchanged)
  • Performance improvement (not claimed)

Scope check

  • I read the contributing guide
  • This fits serpapi-ruby's stated focus
  • This isn't application-specific logic that belongs in user code
  • This benefits users of the documented parser option

Related issue

Fixes #44

Quality check

The compatibility and regression harnesses disabled network access.
The mocked specs used a non-secret invalid placeholder solely
to satisfy the global guard. SimpleCov started after the library loaded,
so its printed coverage is not evidence of coverage completeness.

Ownership

  • I understand every line of this change and can answer questions about it

API changes

  • Breaking change (not intended)
  • New public methods or classes (none)
  • Changed method signatures (none)
  • No API changes

The JSON parser reads only per-call options, ignoring the documented
constructor setting. Archived searches cannot receive a per-call
parser option at all.

Fall back to the constructor setting before the default of true.
Keep explicit per-call overrides and outgoing requests unchanged.

Fixes serpapi#44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Constructor symbolize_names defaults are ignored

1 participant