Skip to content

Instantly share code, notes, and snippets.

@billinkc
Created September 5, 2019 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billinkc/39e0711036918c805457d54630583167 to your computer and use it in GitHub Desktop.
Save billinkc/39e0711036918c805457d54630583167 to your computer and use it in GitHub Desktop.
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