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

Prototype JSON::Coder #718

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

etiennebarrie
Copy link
Contributor

This is still a WIP.

This API allows to use strict mode while defining how to serialize custom objects in a non-global way (without defining to_json on the objects' classes).
It translates into another primitive object supported by JSON and leaves the serialization to the JSON gem.

Co-authored-by: Jean Boussier <[email protected]>
@paddor
Copy link

paddor commented Dec 22, 2024

I love this. That's exactly what I'd need to make sure my Time objects are encoded as ISO8601 with millisecond precision without monkey patching.

Doing this just doesn't feel right:

class Time
  def to_json(*a)
    iso8601(3).to_json(*a)
  end
end

So far I've been relying on Oj's time_format: :xmlschema, second_precision: 3.

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.

2 participants