Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Implement as_json #249

Merged
merged 2 commits into from
Oct 12, 2022
Merged

[Feat] Implement as_json #249

merged 2 commits into from
Oct 12, 2022

Conversation

okuramasafumi
Copy link
Owner

as_json returns a Hash like serializable_hash, but its result is similar to the result of serialize. In other words, as_json is a Hash version of serialize.
Since I changed the root key from String to Symbol, there's one breaking change that affects those who use Oj with object mode.

`as_json` returns a Hash like `serializable_hash`, but its result
is similar to the result of `serialize`. In other words, `as_json`
is a Hash version of `serialize`.
Since I changed the root key from String to Symbol, there's one
breaking change that affects those who use Oj with `object` mode.
@codecov
Copy link

codecov bot commented Oct 11, 2022

Codecov Report

Merging #249 (f18aa18) into main (18a9dc7) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #249   +/-   ##
=======================================
  Coverage   98.90%   98.90%           
=======================================
  Files          11       11           
  Lines         455      455           
=======================================
  Hits          450      450           
  Misses          5        5           
Impacted Files Coverage Δ
lib/alba/resource.rb 99.54% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

This is because there's no "Symbol" in JSON world.
For example, `as_json` method in Rails returns a Hash whose keys
are all String.
https://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html#method-i-as_json
@okuramasafumi okuramasafumi merged commit 2475a3b into main Oct 12, 2022
@okuramasafumi okuramasafumi deleted the as_json branch October 12, 2022 14:14
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.

1 participant