[DataContract]
class JSONContract
{
String50 parmFirst, parmSecond;
List lines = new List (types::Class);
[
DataMemberAttribute('parmFirst')
]
public String50 parmFirst(String50 _parmFirst = parmFirst)
{
parmFirst = _parmFirst;
return parmFirst;
}
[
DataMemberAttribute('parmSecond')
]
public String50 parmSecond(String50 _parmSecond = parmSecond)
{
parmSecond = _parmSecond;
return parmSecond;
}
[DataMemberAttribute('lines'),
DataCollectionattribute(types::class, classstr(JSONLineContract))]
public List parmLines(List _lines = lines)
{
lines = _lines;
return lines;
}
}
[DataContract]
class JSONLineContract
{
String50 parmFirst, parmSecond;
[
DataMemberAttribute('parmFirst')
]
public String50 parmFirst(String50 _parmFirst = parmFirst)
{
parmFirst = _parmFirst;
return parmFirst;
}
[
DataMemberAttribute('parmSecond')
]
public String50 parmSecond(String50 _parmSecond = parmSecond)
{
parmSecond = _parmSecond;
return parmSecond;
}
}
class ReadJson
{
public static void main(Args _args)
{
str json;
List values = new List(Types::Class);
List valuesLines = new List(Types::Class);
ListEnumerator value,valueLines;
json = '[{"FieldValues": [{"parmFirst": "ValueFirst", "parmSecond": "ValueSecond", "lines":[{"parmFirst": "ValueFirst1", "parmSecond": "ValueSecond1"},{"parmFirst": "ValueFirst2", "parmSecond": "ValueSecond2"}] }]}]';
values = FormJsonSerializer::deserializeCollection(classnum(List), json, Types::Class, classStr(JSONContract));
value = values.getEnumerator();
while(value.moveNext())
{
JSONContract JSONContractCurrent = value.current();
info(strfmt('%1',JSONContractCurrent.parmFirst(), JSONContractCurrent.parmSecond()));
valuesLines = JSONContractCurrent.parmLines();
valueLines = valuesLines.getEnumerator();
while(valueLines.moveNext())
{
JSONLineContract JSONLineContractCurrent = valueLines.current();
info(strfmt('%1',JSONLineContractCurrent.parmFirst(), JSONLineContractCurrent.parmSecond()));
}
}
}
}
No comments:
Post a Comment