JRockFL
asked on
Deserialize json using json.net
I'm trying to deseriliaze this json response without luck.
Unable to cast object of type 'Newtonsoft.Json.Linq.JArr ay' to type 'RootObject'.
RootObject rootObject = JsonConvert.DeserializeObj ect(respon seMessage) ;
What Am I doing wrong?
[{"total_collected_money": {"currency _code":"US D","amount ":3497},"t ender":[{" type":"CRE DIT_CARD", "name":"Cr edit Card","total_money":{"curr ency_code" :"USD","am ount":3497 },"card_br and":"AMER ICAN_EXPRE SS","pan_s uffix":"99 99","entry _method":" SWIPED"}], "inclusive _tax_money ":{"curren cy_code":" USD","amou nt":0},"id ":"xxxx"," discount_m oney":{"cu rrency_cod e":"USD"," amount":-1 498},"devi ce":{"name ":"iPad"}, "net_total _money":{" currency_c ode":"USD" ,"amount": 3401},"tax _money":{" currency_c ode":"USD" ,"amount": 0},"creato r_id":"xxx x","mercha nt_id":"xx xx","refun ded_money" :{"currenc y_code":"U SD","amoun t":-13487} ,"inclusiv e_tax":[], "refunds": [{"type":" FULL","cre ated_at":" 2014-02-20 T16:21:32Z ","process ed_at":"20 14-02-20T1 6:21:32Z", "reason":" Canceled Order","refunded_money":{" currency_c ode":"USD" ,"amount": -3497}}]," additive_t ax_money": {"currency _code":"US D","amount ":0},"proc essing_fee _money":{" currency_c ode":"USD" ,"amount": -96},"tip_ money":{"c urrency_co de":"USD", "amount":0 },"additiv e_tax":[], "created_a t":"2014-0 2-20T16:20 :06Z"}]
Unable to cast object of type 'Newtonsoft.Json.Linq.JArr
RootObject rootObject = JsonConvert.DeserializeObj
What Am I doing wrong?
[{"total_collected_money":
public class TotalCollectedMoney
{
public string currency_code { get; set; }
public int amount { get; set; }
}
public class TotalMoney
{
public string currency_code { get; set; }
public int amount { get; set; }
}
public class Tender
{
public string type { get; set; }
public string name { get; set; }
public TotalMoney total_money { get; set; }
public string card_brand { get; set; }
public string pan_suffix { get; set; }
public string entry_method { get; set; }
}
public class InclusiveTaxMoney
{
public string currency_code { get; set; }
public int amount { get; set; }
}
public class DiscountMoney
{
public string currency_code { get; set; }
public int amount { get; set; }
}
public class Device
{
public string name { get; set; }
}
public class NetTotalMoney
{
public string currency_code { get; set; }
public int amount { get; set; }
}
public class TaxMoney
{
public string currency_code { get; set; }
public int amount { get; set; }
}
public class RefundedMoney
{
public string currency_code { get; set; }
public int amount { get; set; }
}
public class RefundedMoney2
{
public string currency_code { get; set; }
public int amount { get; set; }
}
public class Refund
{
public string type { get; set; }
public string created_at { get; set; }
public string processed_at { get; set; }
public string reason { get; set; }
public RefundedMoney2 refunded_money { get; set; }
}
public class AdditiveTaxMoney
{
public string currency_code { get; set; }
public int amount { get; set; }
}
public class ProcessingFeeMoney
{
public string currency_code { get; set; }
public int amount { get; set; }
}
public class TipMoney
{
public string currency_code { get; set; }
public int amount { get; set; }
}
public class RootObject
{
public TotalCollectedMoney total_collected_money { get; set; }
public List<Tender> tender { get; set; }
public InclusiveTaxMoney inclusive_tax_money { get; set; }
public string id { get; set; }
public DiscountMoney discount_money { get; set; }
public Device device { get; set; }
public NetTotalMoney net_total_money { get; set; }
public TaxMoney tax_money { get; set; }
public string creator_id { get; set; }
public string merchant_id { get; set; }
public RefundedMoney refunded_money { get; set; }
public List<object> inclusive_tax { get; set; }
public List<Refund> refunds { get; set; }
public AdditiveTaxMoney additive_tax_money { get; set; }
public ProcessingFeeMoney processing_fee_money { get; set; }
public TipMoney tip_money { get; set; }
public List<object> additive_tax { get; set; }
public string created_at { get; set; }
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That was it.
I have it now. Thank you!
I have it now. Thank you!
RootObject[] rootobject = JsonConvert.DeserializeObject<RootObject[]>(responseMessage);
ASKER