Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to use a json metadata store with Biml
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<#
// Given the following structure
///{
/// "packages": [
/// "p1",
/// "p2",
/// "p3"
/// ]
///}
// Assume the json file is located as specified
string sourceFile = @"C:\ssisdata\trivial.json";
// Read the data into a string variable
string json = System.IO.File.ReadAllText(sourceFile);
// Deserialize the json into a dictionary of strings (packages) and a list of strings (p1, p2, p3)
Dictionary<string, List<string>> metadata = JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(json);
#>
<Packages>
<#
// Shred the dictionary for our values
foreach (string item in metadata["packages"])
{
//WriteLine(String.Format("<!-- {0} -->", item));
#>
<Package Name="<#=item #>" />
<#
}
#>
</Packages>
</Biml>
<#@ import namespace="Newtonsoft.Json" #>
<#* Assuming we have GAC'ed the assembly *#>
<#@ assembly name= "Newtonsoft.Json.dll" #>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment