JSON Deserialization returning null Contract class X++

SylvesterApi
New Member
1 0 0

Dears,

i am trying to deserialize JSON object in x++ using the below code

Myclass VarContract = FormJsonSerializer::deserializeObject(classNum(Myclass ),wsResponse);

myclass contract

 

[datacontract]
class Myclass
{
    list orders;
    [DataMember('orders'),AifCollectionTypeAttribute('orders',Types::Class,classStr(ElementClass))
        ,AifCollectionTypeAttribute('return',Types::Class,classStr(ElementClass))]
    public list ParmOrders(list _orders = orders)
    {
        orders = _orders;
        return orders;
    }

}

 

and the class Element is formated below

 

 

 

[datacontract]
class ElementClass
{
    [DataMember("id")]
    public int64 parmid(int64 _id = id)
    {
        id = _id;
        return id;
    }

       [DataMember("total_line_items_pric")]
    public Str Parmtotal_line_items_price(Str _total_line_items_price = total_line_items_price)
    {
        total_line_items_price = _total_line_items_price;
        return total_line_items_price;
    }

    [DataMember('total_discounts')]
    public Str total_discounts(Str _total_discounts = total_discounts)
    {
        total_discounts = _total_discounts;
        return total_discounts;
    }

    [DataMember('gateway')]
    public Str Parmgateway(Str _gateway = gateway)
    {
        gateway = _gateway;
        return gateway;
    }

    [DataMember('total_price')]
    public Str Parmtotal_price(Str _total_price = total_price)
    {
        total_price = _total_price;
        return total_price;
    }

    [DataMember('subtotal_price')]
    public Str Parmsubtotal_price(Str _subtotal_price = subtotal_price)
    {
        subtotal_price = _subtotal_price;
        return subtotal_price;
    }

}

 

 

 

after the deserialization the List in myclass is returning null knowing that the wsResponse is returning a well formated JSON 

your help is highly appreciated

0 Likes