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

Rework PreciseDate JSON serialisation #52

Open
damien-rivet opened this issue Jan 5, 2018 · 0 comments
Open

Rework PreciseDate JSON serialisation #52

damien-rivet opened this issue Jan 5, 2018 · 0 comments

Comments

@damien-rivet
Copy link
Owner

Context

The PreciseDate class has been constructed to mimic the same behaviour as JSS payload when it comes to dates.

By acception a base key name, it allows the reconstruction of the 3 original keys for any date, like that:

{
    "example_date": "XXX",
    "example_date_epoch": 0,
    "example_date_utc": "XXX+0500"
}

If those keys were embedded in a single key it would have been much more simple to reconstruct the json before sending it to JSS.

An updated payload:

{
    "example_date": {
        "date": "XXX",
        "epoch": 0,
        "utc": "XXX+0500"
    }
}

Which in turn would improve the injection of each date in any JSON payload.

How it's currently done:

if let exampleDate = exampleDate {
    json.merge(exampleDate.toJSON()) { (_, new) in new }
}

Currently, this solution is problematic since the test coverage can't make it inside the block.

Issue

Find a better way of generating / injecting any date's JSON into another JSON payload.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

1 participant