{"id":19016144,"url":"https://github.com/fosskers/microlens-aeson","last_synced_at":"2025-04-14T16:35:11.770Z","repository":{"id":3202546,"uuid":"89646150","full_name":"fosskers/microlens-aeson","owner":"fosskers","description":"Lenses and Traversals for Aeson, based on Microlens.","archived":false,"fork":false,"pushed_at":"2024-06-05T05:21:05.000Z","size":3480,"stargazers_count":14,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T05:13:37.470Z","etag":null,"topics":["aeson","haskell","lens"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fosskers.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-27T22:40:57.000Z","updated_at":"2024-06-05T05:21:09.000Z","dependencies_parsed_at":"2024-02-01T01:28:48.796Z","dependency_job_id":"b3d3cb24-7e73-4b03-bb9e-f1a639735242","html_url":"https://github.com/fosskers/microlens-aeson","commit_stats":{"total_commits":184,"total_committers":24,"mean_commits":7.666666666666667,"dds":0.7445652173913043,"last_synced_commit":"a594a94fe248f205a71ed078d3bb2ad1335cabce"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fosskers%2Fmicrolens-aeson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fosskers%2Fmicrolens-aeson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fosskers%2Fmicrolens-aeson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fosskers%2Fmicrolens-aeson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fosskers","download_url":"https://codeload.github.com/fosskers/microlens-aeson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248917147,"owners_count":21182938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aeson","haskell","lens"],"created_at":"2024-11-08T19:41:24.640Z","updated_at":"2025-04-14T16:35:11.748Z","avatar_url":"https://github.com/fosskers.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"microlens-aeson\n===============\n\n![](https://github.com/fosskers/microlens-aeson/workflows/Tests/badge.svg)\n[![Hackage](https://img.shields.io/hackage/v/microlens-aeson.svg?style=flat)](https://hackage.haskell.org/package/microlens-aeson)\n[![Stackage Nightly](http://stackage.org/package/microlens-aeson/badge/nightly)](http://stackage.org/nightly/package/microlens-aeson)\n[![Stackage LTS](http://stackage.org/package/microlens-aeson/badge/lts)](http://stackage.org/lts/package/microlens-aeson)\n\n`microlens-aeson` provides Traversals for the\n[Aeson](http://hackage.haskell.org/package/aeson) library's `Value` type,\nwhile obeying the `Traversal` laws.\n\n`microlens-aeson` is derived from `lens-aeson`, but is based upon `microlens`\nto reduce the amount of dependencies involved.\n\nHere is the dependency graph for `lens-aeson`:\n\n![lens-aeson dependencies](lens-aeson.png)\n\nAnd that for `microlens-aeson`:\n\n![microlens-aeson dependencies](microlens-aeson.png)\n\nUsage\n-----\n`microlens-aeson` provides Traversals into both lazy and strict variants\nof all the text types. Here are some examples:\n\n```haskell\n{-# LANGUAGE OverloadedStrings #-}\n\nimport Data.Aeson\nimport Data.Text (Text)\nimport Lens.Micro\nimport Lens.Micro.Aeson\n\n--------------------------\n-- Manipulating primatives\n--------------------------\n-- | Optionally getting one value\na :: Maybe Int\na = (\"37\" :: Text) ^? _Integer  -- Just 37\n\n-- | Setting one value within encoded JSON\nb :: Text\nb = (\"true\" :: Text) \u0026 _Bool .~ False  -- \"false\"\n\n----------------------\n-- Manipulating arrays\n----------------------\n-- | Get all values as an Aeson type.\nc :: [Value]\nc = (\"[1, 2, 3]\" :: Text) ^.. values  -- [Number 1.0, Number 2.0, Number 3.0]\n\n-- | Get all values cast to some simpler number type.\nd :: [Double]\nd = (\"[1, 2, 3]\" :: Text) ^.. values . _Double  -- [1.0, 2.0, 3.0]\n\n-- | Access a specific index, and set a `Value` directly.\ne :: Text\ne = \"[1,2,3]\" \u0026 nth 1 .~ Number 20  -- \"[1,20,3]\"\n\n-----------------------\n-- Manipulating objects\n-----------------------\n-- | Access all values of the key/value pairs.\nf :: Text\nf = \"{\\\"a\\\":4,\\\"b\\\":7}\" \u0026 members . _Number %~ (*10)  -- \"{\\\"a\\\":40,\\\"b\\\":70}\"\n\n-- | Access via a given key.\ng :: Maybe Value\ng = (\"{\\\"a\\\": 100, \\\"b\\\": 200}\" :: Text) ^? key \"a\"  -- Just (Number 100.0)\n\n-----------------------------------\n-- Aeson `Value`s from encoded JSON\n-----------------------------------\nh :: Maybe Value\nh = (\"{\\\"a\\\":4,\\\"b\\\":7}\" :: Text) ^? _Value\n-- Just (Object (fromList [(\"a\",Number 4.0),(\"b\",Number 7.0)]))\n```\n\nSee the Haddock documentation for a full API specification.\n\nMigration from Data.Aeson.Lens\n------------------------------\nThe functions provided here are Traversals, not Prisms, therefore\ncreation of encoded JSON from Haskell types like:\n\n```haskell\n\u003e\u003e\u003e _Bool # True :: String\n\"true\"\n```\n\nis no longer possible. Otherwise, if your use cases are strictly like\nthose listed in the Usage section above, then you need only to switch\nthe import from `Data.Aeson.Lens` to `Lens.Micro.Aeson`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffosskers%2Fmicrolens-aeson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffosskers%2Fmicrolens-aeson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffosskers%2Fmicrolens-aeson/lists"}