dimonovdd / MSBuild.CompactJsonResources

Compact Json data by removing whitespaces before building

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MSBuild.CompactJsonResources

header

NuGet Badge license fuget.org

Often, Json files are added to a project as one line to reduce the size of the build. Such files are uncomfortable to read and track changes through version control systems. This package resolve this problem by removing whitespaces, trailing commas and comments from the builds without changing the beautiful Json source files by adding their single-line copies. It also checks Json files before building and warns about missing curly brace and etc.

{
  "null": null, //this is comment
  "number": 123,
  "object": {
    "a": "b",
    "c": "d",
  },
  "string": "Hello World",
}
{"null":null,"number":123,"object":{"a":"b","c":"d"},"string":"Hello World"}

Getting started

  1. Add reference for this package.
  2. Set EnableCompactJson property to true. (When the value is false the files data are not changed)
  3. Just use JsonEmbeddedResource as EmbeddedResource.
<PropertyGroup>
  <EnableCompactJson>true</EnableCompactJson>
</PropertyGroup>
<ItemGroup>
  <JsonEmbeddedResource Include="data.json" />
</ItemGroup>
<ItemGroup>
  <PackageReference Include="MSBuild.CompactJsonResources" Version="1.0.0" PrivateAssets="all"/>
</ItemGroup>

About

Compact Json data by removing whitespaces before building

License:MIT License


Languages

Language:C# 100.0%