{"id":20138471,"url":"https://github.com/thiagobarradas/jsonmasking","last_synced_at":"2025-04-12T19:52:23.560Z","repository":{"id":38310399,"uuid":"148363593","full_name":"ThiagoBarradas/jsonmasking","owner":"ThiagoBarradas","description":"Replace fields in json, replacing by something, don't care if property is in depth objects. Very useful to replace passwords credit card number, etc.","archived":false,"fork":false,"pushed_at":"2024-07-11T13:29:55.000Z","size":69,"stargazers_count":175,"open_issues_count":2,"forks_count":45,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-12T19:52:10.386Z","etag":null,"topics":["dotnet","dotnet-core","dotnet-standard","extension","hidden","json","mask","masking","newtonsoft","remove","replace","utility","wildcard"],"latest_commit_sha":null,"homepage":null,"language":"C#","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/ThiagoBarradas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","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":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-11T18:43:24.000Z","updated_at":"2025-02-02T22:02:03.000Z","dependencies_parsed_at":"2024-06-18T14:04:43.743Z","dependency_job_id":"ec8d6968-0f2d-4589-b687-db0c56330bee","html_url":"https://github.com/ThiagoBarradas/jsonmasking","commit_stats":{"total_commits":69,"total_committers":1,"mean_commits":69.0,"dds":0.0,"last_synced_commit":"8689a83560d5868302d667afb3b0835b9d829054"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiagoBarradas%2Fjsonmasking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiagoBarradas%2Fjsonmasking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiagoBarradas%2Fjsonmasking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiagoBarradas%2Fjsonmasking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThiagoBarradas","download_url":"https://codeload.github.com/ThiagoBarradas/jsonmasking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625507,"owners_count":21135513,"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":["dotnet","dotnet-core","dotnet-standard","extension","hidden","json","mask","masking","newtonsoft","remove","replace","utility","wildcard"],"created_at":"2024-11-13T21:38:15.944Z","updated_at":"2025-04-12T19:52:23.521Z","avatar_url":"https://github.com/ThiagoBarradas.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://barradas.visualstudio.com/Contributions/_apis/build/status/NugetPackage/JsonMasking?branchName=develop)](https://barradas.visualstudio.com/Contributions/_build/latest?definitionId=1\u0026branchName=develop)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ThiagoBarradas_jsonmasking\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=ThiagoBarradas_jsonmasking)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ThiagoBarradas_jsonmasking\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=ThiagoBarradas_jsonmasking)\n[![NuGet Downloads](https://img.shields.io/nuget/dt/JsonMasking.svg)](https://www.nuget.org/packages/JsonMasking/)\n[![NuGet Version](https://img.shields.io/nuget/v/JsonMasking.svg)](https://www.nuget.org/packages/JsonMasking/)\n\n# Json Masking \n\nReplace fields in json, replacing by something, don't care if property is in depth objects. Very useful to replace passwords, credit card number, etc.\n\nThis library matching insensitive values with field namespaces. You can use wildcard * to allow any char in pattern;\n\n# Sample\n\n```c#\n\n- Completely masking some of the properties\n\nvar example = new \n{\n\tSomeValue = \"Demo\",\n\tPassword = \"SomePasswordHere\",\n\tDepthObject = new \n\t{\n\t\tPassword = \"SomePasswordHere2\",\n\t\tCard = new \n\t\t{\n\t\t\tNumber = \"555500022223333\"\n\t\t}\n\t},\n\tCreditCardNumber = \"5555000011112222\",\n\tCard = new \n\t{\n\t\tNumber = \"555500022223333\"\n\t}\n};\n\nvar exampleAsString = JsonConvert.Serialize(example); // value must be a json string to masked\n\n// note that password is only replaced when is in root path\nvar blacklist = new string[] { \"password\", \"card.number\", \"*.card.number\" \"creditcardnumber\" };\nvar mask = \"******\";\n\nvar maskedExampleAsString = exampleAsString.MaskFields(blacklist, mask);\n\nConsole.WriteLine(maskedExampleAsString);\n\n```\n\nOutput\n```json\n{\n\t\"SomeValue\" : \"Demo\",\n\t\"Password\" : \"******\",\n\t\"DepthObject\" : {\n\t\t\"Password\" : \"SomePasswordHere2\",\n\t\t\"Card\" : {\n\t\t\t\"Number\" : \"******\"\n\t\t}\n\t},\n\t\"CreditCardNumber\" : \"******\",\n\t\"Card\" : {\n\t\t\"Number\" : \"******\"\n\t}\n}\n```\n\n```c#\n\n- Partially masking some of the properties\n\nvar example = new \n{\n\tSomeValue = \"Demo\",\n\tPassword = \"SomePasswordHere\",\n\tDepthObject = new \n\t{\n\t\tPassword = \"SomePasswordHere2\",\n\t\tCard = new \n\t\t{\n\t\t\tNumber = \"555500022223333\"\n\t\t}\n\t},\n\tCreditCardNumber = \"5555000011112222\",\n\tCard = new \n\t{\n\t\tNumber = \"555500022223333\"\n\t}\n};\n\nvar blacklistPartial = new Dictionary\u003cstring, Func\u003cstring, string\u003e\u003e(StringComparer.OrdinalIgnoreCase) // The key is the property to be partially masked and the value is the function to be applied.\n{\n    { \"*card.number\", text =\u003e  // Note that the property \"*card.number\" is also in the blacklist. If the property only exists in the blacklistPartial, it will not be masked.\n        Regex.Replace(\n            text,\n            @\"(\\d{4,5})[ -|]?(\\d{3,6})[ -|]?(\\d{3,5})[ -|]?(\\d{3,4})\",\n            match =\u003e $\"{match.Value.Substring(0, 6)}*****{match.Value.Substring(match.Value.Length - 4, 4)}\")\n    }\n};\n\nvar exampleAsString = JsonConvert.Serialize(example); // The value must be a JSON string to be masked.\n\n// Note that the password is only replaced when it is in the root path.\nvar blacklist = new string[] { \"password\", \"*card.number\", \"creditcardnumber\" };\nvar mask = \"******\";\n\nvar maskedExampleAsString = exampleAsString.MaskFields(blacklist, mask, blacklistPartial); // The blacklistPartial is optional. If provided, it will apply the mask only if the property is also in the blacklist.\n\nConsole.WriteLine(maskedExampleAsString);\n\n```\n\nOutput\n```json\n{\n\t\"SomeValue\" : \"Demo\",\n\t\"Password\" : \"******\",\n\t\"DepthObject\" : {\n\t\t\"Password\" : \"SomePasswordHere2\",\n\t\t\"Card\" : {\n\t\t\t\"Number\" : \"555500*****3333\"\n\t\t}\n\t},\n\t\"CreditCardNumber\" : \"******\",\n\t\"Card\" : {\n\t\t\"Number\" : \"555500*****3333\"\n\t}\n}\n```\n\n## Install via NuGet\n\n```\nPM\u003e Install-Package JsonMasking\n```\n\n## How can I contribute?\nPlease, refer to [CONTRIBUTING](.github/CONTRIBUTING.md)\n\n## Found something strange or need a new feature?\nOpen a new Issue following our issue template [ISSUE_TEMPLATE](.github/ISSUE_TEMPLATE.md)\n\n## Changelog\nSee in [nuget version history](https://www.nuget.org/packages/JsonMasking)\n\n## Did you like it? Please, make a donate :)\n\nif you liked this project, please make a contribution and help to keep this and other initiatives, send me some Satochis.\n\nBTC Wallet: `1G535x1rYdMo9CNdTGK3eG6XJddBHdaqfX`\n\n![1G535x1rYdMo9CNdTGK3eG6XJddBHdaqfX](https://i.imgur.com/mN7ueoE.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiagobarradas%2Fjsonmasking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthiagobarradas%2Fjsonmasking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiagobarradas%2Fjsonmasking/lists"}