Hello,
i've played with C# to generate a serialized json array, with the Newtonsoft library, that is shipped into ZP as well.
- I do use the Custom Code C# block (not the Cube yet)
- My code does not have any error outside ZP, the log console still indicated have some syntax issues.
- All my brackets are correctly closed, seems it is more a library or Zenno call syntax issue
- After some read in the russian forums, i've activated Newtonsoft, through GAC, even if i do not know really why i need to do this.
Did i miss something to be able to play correctly with C#, ZP and Newtonsoft syntax ?
Do i need to activate something so it works well ?
How to check if the Newtonsoft is correctly loaded ?
Is it a syntax error on the very last line, that generates the agregated json (the json string) ?
thanks for your help
i've played with C# to generate a serialized json array, with the Newtonsoft library, that is shipped into ZP as well.
- I do use the Custom Code C# block (not the Cube yet)
- My code does not have any error outside ZP, the log console still indicated have some syntax issues.
- All my brackets are correctly closed, seems it is more a library or Zenno call syntax issue
- After some read in the russian forums, i've activated Newtonsoft, through GAC, even if i do not know really why i need to do this.
Did i miss something to be able to play correctly with C#, ZP and Newtonsoft syntax ?
Do i need to activate something so it works well ?
How to check if the Newtonsoft is correctly loaded ?
Is it a syntax error on the very last line, that generates the agregated json (the json string) ?
JsonConvert lists:
public class Coordinate
{
public int x1 { get; set; }
public int x2 { get; set; }
public int y1 { get; set; }
public int y2 { get; set; }
}
public class GroupeRef
{
public int product_id { get; set; }
public int product_index { get; set; }
public int advised_qty { get; set; }
public List<Coordinate> coordinates { get; set; } = new List<Coordinate>();
}
GroupeRef reference1 = new GroupeRef()
{
product_id = 75851,
product_index = 1,
coordinates = new List<Coordinate>()
{
new Coordinate()
{
x1 = 356,
x2 = 356,
y1 = 560,
y2 = 560
}
},
advised_qty = 1
};
GroupeRef reference2 = new GroupeRef()
{
product_id = 46807,
product_index = 2,
coordinates = new List<Coordinate>()
{
new Coordinate()
{
x1 = 397,
x2 = 397,
y1 = 560,
y2 = 560
}
},
advised_qty = 10
};
List<GroupeRef> references = new List<GroupeRef>() { reference1, reference2};
string json = Global.ZennoLab.Json.JsonConvert.SerializeObject(references);
Вложения
-
15,1 КБ Просмотры: 38
-
19,8 КБ Просмотры: 40
-
8 КБ Просмотры: 43