Skip to content

Conversation

@mchaver
Copy link

@mchaver mchaver commented Oct 1, 2024

#36

@Vlix
Copy link
Owner

Vlix commented Oct 15, 2024

Thank you for the PR! 🙏

I'll try to review this more seriously in the next month.

Copy link
Owner

@Vlix Vlix left a comment

Choose a reason for hiding this comment

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

Also please update the package.yaml's version to 1.2.1.0

safeToJSON
, safeFromJSON
, strippedSafeToJSON
, strippedEncode
Copy link
Owner

Choose a reason for hiding this comment

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

I feel these functions should be added under the Version section. The context there makes more sense and would be better when describing why these functions exist.

    , Version
    , noVersion
    , setVersion
    , setVersion'
    , getVersion
    -- *** Removing the 'SafeJSON' version
    --
    -- | Sometimes you might want (or need) to produce JSON without `SafeJSON` versioning.
    --   Maybe you don't want to leak internals to third parties, or the version fields are
    --   irrelevant and only clutter in a specific instance.
    --   Regardless of the case, if you don't need to parse the JSON again, these functions
    --   can be used to remove the `SafeJSON` versioning.
    , removeVersion
    , strippedSafeToJSON
    , strippedEncode

And then we'll give a bit more context per function.

@@ -1,5 +1,8 @@
# Changelog for safe-json

## 1.3.0.0
Copy link
Owner

Choose a reason for hiding this comment

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

This would be a minor version increase. 1.2.1.0

typeName _ = "Product"
version = noVersion

-- | safeToJSON with the version removed
Copy link
Owner

Choose a reason for hiding this comment

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

-- | 'safeToJSON' without any `SafeJSON` versioning.
--   Effectively the same as 'Data.Aeson.toJSON', but using the 'safeTo' method.
--
--   Sometimes you don't need (or want) the versioning, so if you don't need to parse
--   the 'Data.Aeson.Value' later on, this is a convenience function to easily 
--   remove the version fields from the resulting JSON. 
-- 
-- @
-- strippedSafeToJSON = 'removeVersion' . 'safeToJSON'
-- @
-- 
-- @since 1.2.1.0

strippedSafeToJSON :: forall a. SafeJSON a => a -> Value
strippedSafeToJSON = removeVersion . safeToJSON

-- | encode with version removed
Copy link
Owner

Choose a reason for hiding this comment

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

-- | Encode a 'SafeJSON' value to a 'LBS.ByteString' without SafeJSON versioning.
--
--   Like this package's own 'Data.Aeson.Safe.encode' function,
--   but without version fields in the resulting 'LBS.ByteString'.
--
-- @
-- strippedEncode = 'Data.Aeson.encode' . 'strippedSafeToJSON'
-- @
-- 
-- @since 1.2.1.0

@Vlix
Copy link
Owner

Vlix commented Oct 19, 2024

Oh, and rebase onto master, please. The CI has been fixed.

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