Closed pranavdhundhia closed 5 years ago
Got it resolved by adding latest version(Liquid.NET -Version 0.10.0) Previously was using 0.9.0
`[Fact]
public void Test_JsonToJsonParser()
{
var errors = new List
List<Sales> SalesList = new List<Sales>
{
new Sales {SalesId = 1,ProductName="Some name",Quantity =30},
new Sales {SalesId = 2,ProductName="Some name1",Quantity =30},
new Sales {SalesId = 3,ProductName="Some name2",Quantity =30}
};
List<Orders> ProductList = new List<Orders>
{
new Orders {OrderId = 1,ProductName="Some name",Quantity =30},
new Orders {OrderId = 2,ProductName="Some name1",Quantity =30},
new Orders {OrderId = 3,ProductName="Some name2",Quantity =30}
};
ctx.DefineLocalVariable("content", ProductList.ToLiquid());
// Note that you will still get a best-guess LiquidTemplate, even if you encounter errors.
var liquidTemplate = LiquidTemplate.Create(@"[
{% for sales in content %}
{
""SalesId"": {{sales.orderid}},
""ProductName"": ""{{sales.productname}}"",
""Quantity"": {{sales.quantity}}
},
{% endfor %}
]").OnParsingError(errors.Add)
.LiquidTemplate;
var resultdata = liquidTemplate.Render(ctx).Result;
IEnumerable<Sales> salesresult = JsonConvert.DeserializeObject<List<Sales>>(resultdata);
Assert.Equal(salesresult.Count(), SalesList.Count());
}`
Got it resolved by adding latest version(Liquid.NET -Version 0.10.0) Previously was using 0.9.0
` List ProductList = new List
{
new Orders {OrderId = 1,ProductName="Some name",Quantity =30},
new Orders {OrderId = 1,ProductName="Some name1",Quantity =30},
new Orders {OrderId = 1,ProductName="Some name2",Quantity =30}
};
Parsing Liquid object to json . No conversion done.