Skip to content

[BAC-273] Stringify keys in from_json call - #18

Merged
taleh007 merged 1 commit into
masterfrom
feature/BAC-273
Jul 23, 2025
Merged

[BAC-273] Stringify keys in from_json call#18
taleh007 merged 1 commit into
masterfrom
feature/BAC-273

Conversation

@taleh007

@taleh007 taleh007 commented Jul 8, 2025

Copy link
Copy Markdown
Contributor

☝️

@taleh007
taleh007 requested review from HolyWalley and yard July 8, 2025 12:55
# Class-level methods.
module ClassMethods
def from_json(json)
unified_json = json.stringify_keys

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deep stringify keys? Or nested entities will be handled by their own from_json?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, I expect so

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will with_indifferent_access be a better/faster alternative?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no method with_indifferent_access an instance of ActionController::Parameters

person = ParsersTest::Person.from_json(source)

expect(person).to be_valid
expect(person.as_json.deep_symbolize_keys).to eq({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it just be to eq(source)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, source have camelized keys

@taleh007
taleh007 merged commit 820d0f5 into master Jul 23, 2025
1 check passed
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.

3 participants