我正在向客户发送 100 万个FOOjson列表。
public class FOO
{
public string Foo, Name, Call, Loc, ID;
public double Long, Lat;
public string[] Adr, OpenningHours;
}
但是客户要求我提供特定的输出,因为它会减少数据大小:
删除属性名称,加入地址,并列出他们将永远是一周中的 7 天。喜欢:
[
[
"ag",
99.0000000,
9.0000000,
"FOO-FOO BAR",
"ADR1|ADR2|ADR3|ADR4",
"0101",
"07:30-12:00,12:00-19:30",
"07:30-12:00,12:00-19:30",
"07:30-12:00,12:00-19:30",
"07:30-12:00,12:00-19:30",
"07:30-12:00,12:00-19:30",
"07:30-13:00,",
",",
"07H30",
"FOO BAR"
],
]
我对 Address join 或 flatern OpenningHours 没有任何问题。使用:
public class ItemMapper
{
public string Foo, Name, Adr, ID, Call, Loc,
w1, w2, w3, w4, w5, w6, w7;
public double Long, Lat;
}
return
new ItemMapper
{
Foo = this.Foo,
// [...]
Adr = string.Join("|", this.Adr),
w1 = this.OpenningHours[0],
// [...]
w7= this.OpenningHours[6]
};
没有纯字符串操作替换等,是否有正确的方法来做到这一点?
List 的序列化给出了一个糟糕的结果,我用编译的正则表达式 remplace 修复了这个结果:
[
{ <-- Not a []
"PopertyName":"PropertyValue", <-- Poperty Name, and :
// ..
"PopertyName":"PropertyValue",
},
]
慕哥6287543
相关分类