Created
September 5, 2019 15:39
-
-
Save billinkc/39e0711036918c805457d54630583167 to your computer and use it in GitHub Desktop.
How to use a json metadata store with Biml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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