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"}
- Add reference for this package.
- Set
EnableCompactJson
property totrue
. (When the value isfalse
the files data are not changed) - Just use
JsonEmbeddedResource
asEmbeddedResource
.
<PropertyGroup>
<EnableCompactJson>true</EnableCompactJson>
</PropertyGroup>
<ItemGroup>
<JsonEmbeddedResource Include="data.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MSBuild.CompactJsonResources" Version="1.0.0" PrivateAssets="all"/>
</ItemGroup>