In my ASP.NET MVC Web project, I have got a number of JSON files lying around.
File1.json
{
"manage_employees_section_title":
{
"value": "Manage employees",
"description": "The mange employees section title"
}
}
File2.json
{
"manage_operations_section_title":
{
"value": "Manage operations
"description": "The mange operations section title"
}
}
I need to as part of my build process get all my JSONs and merge into one single file.
I have used MSBuild like this.
<Target Name="ConcatenateJsFiles">
<ItemGroup>
<ConcatFiles Include="Application\**\resource-content*.json"/>
</ItemGroup>
<ReadLinesFromFile File="%(ConcatFiles.Identity)">
<Output TaskParameter="Lines" ItemName="ConcatLines"/>
</ReadLinesFromFile>
<WriteLinesToFile File="Infrastructure\Content\Store\ContentStore.json" Lines="@(ConcatLines)" Overwrite="true" />
</Target>
And this is what I got...
Concat.json
//What I got
{
"manage_employees_section_title":
{
"value": "Manage employees",
"description": "The mange employees section title"
}
}
{
"manage_operations_section_title":
{
"value": "Manage operations
"description": "The mange operations section title"
}
}
Even though I have achieved my goal of concatenation, what I really want is to merge all JSON files into one JSON object.
//What I really want
{
"manage_employees_section_title":
{
"value": "Manage employees",
"description": "The mange employees section title"
},
"manage_operations_section_title":
{
"value": "Manage operations
"description": "The mange operations section title"
}
}
How can I achieve this as part of my build process with Visual Studio.
Many thanks in advance guys..