jackc / jackc/tod

Suggestions on formatting JSON serialization?

Open
#86 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
447
Forks
56
PR merge metrics
No merged PRs in 30d

Description

Hello! Experimenting with the gem with a basic rails api - any suggestions on a good entry point/mechanism for customizing the JSON output of a ActiveRecord attribute storing a Tod::TimeOfDay? I'd like to show the outpost as a '11:00:00' for example rather than the components.

I'm just using a simple `as_json` for my models. There's lots of ways of doing this of course, adding a method that does the string formatting, using ActiveModelSerializers and overriding the attribute getter, but I'd like to find a higher-level way of customizing the output, if possible. Thank you!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Rails API's model as_json path and the Tod::TimeOfDay attribute mentioned in the issue. Compare the possible entry points—custom string formatting, ActiveModelSerializers, and overriding the attribute getter—and clarify which supported mechanism should produce "11:00:00" rather than component fields. Done means a documented, tested way to obtain that JSON output.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.