简体   繁体   English

无法将当前的 JSON object(例如 {“name”:“value”})反序列化为 List 的类型 Collection

[英]Cannot deserialize the current JSON object (e.g. {“name”:“value”}) into type Collection of List

I'm converting json to list of Model in C#, but this is making exception, In my Json response, i'm receiving GUID type, i don't know how to convert in model binding. I'm converting json to list of Model in C#, but this is making exception, In my Json response, i'm receiving GUID type, i don't know how to convert in model binding.

    client = new FireSharp.FirebaseClient(config);
    FirebaseResponse response = await client.GetAsync("Products/");
    var o = JsonConvert.DeserializeObject<Products>(response.Body);
    Products obj = response.ResultAs<Products>();
    var listOfProducts = response.ResultAs<List<Products>>();
    return View(listOfProducts);





  The below is my Json response,

    {"806CACEC-4D99-4EF5-935E-E4FAD8A6529C":{"categories":"Featured|Fish|Rice","productDescription":"New complete product\nThis is the test description to check how much space is taken by it. So just filling some random thing here and there. Also we need to limit the size of the description based on how much space it can take else admin can enter a very big description just like this. :)","productImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","productName":"Schezwan Fried Rice","sizes":[{"goodFor":1,"price":"7.77","size":"Small"},{"goodFor":2,"price":"8.88","size":"Medium"},{"goodFor":3,"price":"9.99","size":"Large"}],"stockAmount":"Yes"},"F977ADF3-7820-4CC6-9A11-B59CA7D62041":{"categories":"Chicken|Rice|Featured","productDescription":"Fried rice dish","productImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","productName":"Fried Rice ","sizes":[{"goodFor":1,"price":"2.95","size":"Small"},{"goodFor":2,"price":"3.95","size":"Medium"},{"goodFor":3,"price":"4.95","size":"Large"}],"stockAmount":"Yes"}}



 i've another response, what will be the code to extract below response,

{"EYr9acl0M4YYE08k426TKNPbv8J3":{"02CBD688-C6F9-44B1-A62F-EDC6EE685DE8":{"email":"nimitknd@gmail.com","fullname":"Nimit Kalaria","orderIsDelivery":true,"orderItems":[{"orderItemAmount":"7.77","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$7.77","orderItemSize":"Regular","orderQuantity":"1"},{"orderItemAmount":"19.98","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$9.99","orderItemSize":"Large","orderQuantity":"2"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1521278785.31225","orderTimezoneIdentifier":"Asia/Kolkata","orderTotalAmount":"27.75","orderUserAddress":"test5, city5, 55555, state5","phoneNumber":"(973) 194-4040","userId":"EYr9acl0M4YYE08k426TKNPbv8J3"},"054B7B1A-0F7A-49E9-BCAC-CC20E63538D1":{"email":"nimitknd@gmail.com","fullname":"Nimit Kalaria","orderIsDelivery":true,"orderItems":[{"orderItemAmount":"5.90","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$2.95","orderItemSize":"Regular","orderQuantity":"2"},{"orderItemAmount":"7.90","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$3.95","orderItemSize":"Medium","orderQuantity":"2"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1537453527.02233","orderTimezoneIdentifier":"Asia/Kolkata","orderTotalAmount":"13.80","orderUserAddress":"test5, city5, 55555, state5","phoneNumber":"(973) 194-4040","userId":"EYr9acl0M4YYE08k426TKNPbv8J3"},"0872BD6B-F5FE-4036-A6B0-9D19AE8ECD31":{"email":"nimitknd@gmail.com","fullname":"Nimit Kalaria","orderIsDelivery":true,"orderItems":[{"orderItemAmount":"26.64","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$8.88","orderItemSize":"Medium","orderQuantity":"3"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1521277982.70246","orderTimezoneIdentifier":"Asia/Kolkata","orderTotalAmount":"26.64","orderUserAddress":"doing test address, tedt, 123456, test","phoneNumber":"(973) 194-4040","userId":"EYr9acl0M4YYE08k426TKNPbv8J3"},"1A7E73C5-B9A1-4162-9812-2154142C287D":{"email":"nimitknd@gmail.com","fullname":"Nimit Kalaria","orderIsDelivery":true,"orderItems":[{"orderItemAmount":"17.76","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$8.88","orderItemSize":"Medium","orderQuantity":"2"},{"orderItemAmount":"7.9","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$3.95","orderItemSize":"Medium","orderQuantity":"2"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1521317743.81503","orderTimezoneIdentifier":"Asia/Kolkata","orderTotalAmount":"25.66","orderUserAddress":"test5, city5, 55555, state5","phoneNumber":"(973) 194-4040","userId":"EYr9acl0M4YYE08k426TKNPbv8J3"},"1F54A117-F7E9-4B2E-876F-9D1135904F11":{"email":"nimitknd@gmail.com","fullname":"Nimit Kalaria","orderIsDelivery":true,"orderItems":[{"orderItemAmount":"26.64","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$8.88","orderItemSize":"Medium","orderQuantity":"3"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1520756940.0","orderTimezoneIdentifier":"America/Chicago","orderTotalAmount":"26.64","orderUserAddress":"doing test address, tedt, 123456, test","phoneNumber":"(973) 194-4040","userId":"EYr9acl0M4YYE08k426TKNPbv8J3"},"2E650B47-7F6F-4D5F-8D2E-F8674F99A37A":{"email":"nimitknd@gmail.com","fullname":"Nimit Kalaria","orderIsDelivery":true,"orderItems":[{"orderItemAmount":"26.64","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$8.88","orderItemSize":"Medium","orderQuantity":"3"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1520759280.0","orderTimezoneIdentifier":"America/Chicago","orderTotalAmount":"26.64","orderUserAddress":"doing test address, tedt, 123456, test","phoneNumber":"(973) 194-4040","userId":"EYr9acl0M4YYE08k426TKNPbv8J3"},"4380CE47-9F2A-4573-8B07-74117588AC83":{"email":"nimitknd@gmail.com","fullname":"Nimit Kalaria","orderIsDelivery":true,"orderItems":[{"orderItemAmount":"2.95","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$2.95","orderItemSize":"Regular","orderQuantity":"1"},{"orderItemAmount":"3.95","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$3.95","orderItemSize":"Medium","orderQuantity":"1"},{"orderItemAmount":"8.88","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$8.88","orderItemSize":"Medium","orderQuantity":"1"},{"orderItemAmount":"7.77","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$7.77","orderItemSize":"Regular","orderQuantity":"1"},{"orderItemAmount":"9.99","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$9.99","orderItemSize":"Large","orderQuantity":"1"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1521294456.67573","orderTimezoneIdentifier":"Asia/Kolkata","orderTotalAmount":"33.54","orderUserAddress":"doing test address, tedt, 123456, test","phoneNumber":"(973) 194-4040","userId":"EYr9acl0M4YYE08k426TKNPbv8J3"},"854FC878-77D2-40D7-8096-7135F12A6E81":{"email":"nimitknd@gmail.com","fullname":"Nimit Kalaria","orderIsDelivery":true,"orderItems":[{"orderItemAmount":"7.77","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$7.77","orderItemSize":"Regular","orderQuantity":"1"},{"orderItemAmount":"29.97","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$9.99","orderItemSize":"Large","orderQuantity":"3"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1521294647.52492","orderTimezoneIdentifier":"Asia/Kolkata","orderTotalAmount":"37.74","orderUserAddress":"test5, city5, 55555, state5","phoneNumber":"(973) 194-4040","userId":"EYr9acl0M4YYE08k426TKNPbv8J3"},"C2FB998F-341A-4FAD-90AB-A5C6226B1FD4":{"email":"nimitknd@gmail.com","fullname":"Nimit Kalaria","orderIsDelivery":true,"orderItems":[{"orderItemAmount":"7.77","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$7.77","orderItemSize":"Regular","orderQuantity":"1"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1519554240.0","orderTimezoneIdentifier":"America/Chicago","orderTotalAmount":"7.77","orderUserAddress":"doing test address, tedt, 123456, test","phoneNumber":"1234567890","userId":"EYr9acl0M4YYE08k426TKNPbv8J3"}},"fiCJGAaBVqg70zD7Ahk2LKt57A33":{"056B0822-F0A0-4F05-AF72-A9A4280CAE2A":{"orderItems":[{"orderItemAmount":"14.75","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$2.95","orderItemSize":"Regular","orderQuantity":"5"},{"orderItemAmount":"7.9","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$3.95","orderItemSize":"Medium","orderQuantity":"2"},{"orderItemAmount":"9.9","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$4.95","orderItemSize":"Large","orderQuantity":"2"},{"orderItemAmount":"7.77","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$7.77","orderItemSize":"Regular","orderQuantity":"1"},{"orderItemAmount":"19.98","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$9.99","orderItemSize":"Large","orderQuantity":"2"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1513253700.0","orderTimezoneIdentifier":"America/Chicago","orderTotalAmount":"60.3","userId":"fiCJGAaBVqg70zD7Ahk2LKt57A33"},"69101F56-D176-433A-A27F-F8F604C15118":{"orderIsDelivery":true,"orderItems":[{"orderItemAmount":"5.9","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$2.95","orderItemSize":"Regular","orderQuantity":"2"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1519113480.0","orderTimezoneIdentifier":"America/Chicago","orderTotalAmount":"5.9","orderUserAddress":"3 Enterprise Drive, Stratford , 06615, CT","phoneNumber":"44444444444","userId":"fiCJGAaBVqg70zD7Ahk2LKt57A33"},"A4BA58B8-8F80-4E9B-AAB6-F2245278C8E1":{"orderIsDelivery":true,"orderItems":[{"orderItemAmount":"5.9","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$2.95","orderItemSize":"Regular","orderQuantity":"2"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1518767640.0","orderTimezoneIdentifier":"America/Chicago","orderTotalAmount":"5.9","orderUserAddress":"3 Enterprise Drive, Stratford , 06615, CT","phoneNumber":"646283234","userId":"fiCJGAaBVqg70zD7Ahk2LKt57A33"},"ED0B9D33-2F93-4A35-BFB6-4B5A367B76C4":{"email":"olunic@gmail.com","fullname":"Olu","orderIsDelivery":true,"orderItems":[{"orderItemAmount":"14.75","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$2.95","orderItemSize":"Regular","orderQuantity":"5"},{"orderItemAmount":"7.9","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$3.95","orderItemSize":"Medium","orderQuantity":"2"},{"orderItemAmount":"9.9","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$4.95","orderItemSize":"Large","orderQuantity":"2"},{"orderItemAmount":"7.77","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$7.77","orderItemSize":"Regular","orderQuantity":"1"},{"orderItemAmount":"19.98","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$9.99","orderItemSize":"Large","orderQuantity":"2"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1515240720.0","orderTimezoneIdentifier":"America/Chicago","orderTotalAmount":"60.3","phoneNumber":"123445566","userId":"fiCJGAaBVqg70zD7Ahk2LKt57A33"}},"mRqzmatsBuRrwiJIJ6w2MUe7yx33":{"3419F8B9-BDF3-4148-9DC9-685C0EBFCE39":{"email":"onicholson@hostfiniti.net","fullname":"olu n","orderIsDelivery":true,"orderItems":[{"orderItemAmount":"44.4","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$8.88","orderItemSize":"Medium","orderQuantity":"5"},{"orderItemAmount":"29.5","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$2.95","orderItemSize":"Regular","orderQuantity":"10"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1520432040.0","orderTimezoneIdentifier":"America/Chicago","orderTotalAmount":"73.90","orderUserAddress":"7 Warwick Ave, stratfor, 06615, cy","phoneNumber":"6462832242","userId":"mRqzmatsBuRrwiJIJ6w2MUe7yx33"},"8A84E8AD-C4C4-4B47-AFB0-39880A056932":{"email":"onicholson@hostfiniti.net","fullname":"olu n","orderIsDelivery":false,"orderItems":[{"orderItemAmount":"44.4","orderItemCategory":"RICE","orderItemCode":"806CACEC-4D99-4EF5-935E-E4FAD8A6529C","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2F806CACEC-4D99-4EF5-935E-E4FAD8A6529C%2Fimage0?alt=media&token=90a64e8c-f03c-43ee-8bdb-ea4b3334912d","orderItemName":"Fried Rice","orderItemPrice":"$8.88","orderItemSize":"Medium","orderQuantity":"5"},{"orderItemAmount":"29.5","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$2.95","orderItemSize":"Regular","orderQuantity":"10"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1520463900.0","orderTimezoneIdentifier":"America/Chicago","orderTotalAmount":"73.90","phoneNumber":"6462832242","userId":"mRqzmatsBuRrwiJIJ6w2MUe7yx33"}},"ue6N51P9OFOrQgRBgutmJ48Hky22":{"667D44AF-FB0D-4656-8392-47DBAFFDE564":{"email":"onicholson@hostfiniti.org","fullname":"olu nic","orderIsDelivery":false,"orderItems":[{"orderItemAmount":"19.8","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$4.95","orderItemSize":"Large","orderQuantity":"4"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1520464680.0","orderTimezoneIdentifier":"America/Chicago","orderTotalAmount":"19.80","phoneNumber":"16462832242","userId":"ue6N51P9OFOrQgRBgutmJ48Hky22"},"91F01103-9924-4B09-A325-A3B46F2B9536":{"email":"onicholson@hostfiniti.org","fullname":"olu nic","orderIsDelivery":false,"orderItems":[{"orderItemAmount":"19.8","orderItemCategory":"RICE","orderItemCode":"F977ADF3-7820-4CC6-9A11-B59CA7D62041","orderItemImage":"https://firebasestorage.googleapis.com/v0/b/amrestaurant-c56b4.appspot.com/o/Products%2FF977ADF3-7820-4CC6-9A11-B59CA7D62041%2Fimage0?alt=media&token=798c6a99-3cf9-45d2-abd5-9da9593cb8e1","orderItemName":"Fried Rice ","orderItemPrice":"$4.95","orderItemSize":"Large","orderQuantity":"4"}],"orderPaymentMode":"Cash","orderStatus":"On the way","orderTimestamp":"1521358768.40113","orderTimezoneIdentifier":"America/New_York","orderTotalAmount":"19.80","phoneNumber":"(164) 628-3224","userId":"ue6N51P9OFOrQgRBgutmJ48Hky22"}}}

And this is my model,

        public class Products
        {
            public string categories { get; set; }
            public string productDescription { get; set; }
            public string productImage { get; set; }
            public string productName { get; set; }
            public List<Sizes> sizes { get; set; }
            public string stockAmount { get; set; }
        }
        public class Sizes
        {
            public int goodFor { get; set; }
            public decimal price { get; set; }
            public string size { get; set; }
        }

A collection would be [{},{}] .一个集合是[{},{}]

Your input is a single object.您的输入是单个 object。

It very common to wrap collections in an object before returning them (it's linked to security , search for 'top level json arrays').在返回之前将 collections 包装在 object 中是很常见的(它与安全性相关,搜索“顶级 json 数组”)。


You may need to create a wrapper object您可能需要创建一个包装器 object

public WithProducts {
public List<Products> Products { get; set; } // Guessing. See what the collection is called in the result
}
(...)

JsonConvert.Deserialise<WithProducts>(json);

Btw.顺便提一句。 It's good practice to use a singular noun for class names eg Product , Size so you don't end up with var oneProduct = new Products() {...} .对 class 名称使用单数名词是一种很好的做法,例如ProductSize ,这样您就不会以var oneProduct = new Products() {...}结尾。

Because of the GUID key, the returned data can be converted to a Dictionary<string, Propducts> and the desired data extracted from the parsed dictionary由于 GUID 键,返回的数据可以转换为Dictionary<string, Propducts>并从解析的字典中提取所需的数据

//...

FirebaseClient client = new FireSharp.FirebaseClient(config);
FirebaseResponse response = await client.GetAsync("Products/");
Dictionary<string, Products> data = response.ResultAs<Dictionary<string, Products>>();
List<Products>() listOfProducts = data.Select(kvp => kvp.Value).ToList();
return View(listOfProducts);

While the original data shown has one result.虽然显示的原始数据只有一个结果。 The above answer will also work when the object has multiple keys when the response has more than one item.当 object 有多个键且响应有多个项目时,上述答案也将起作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法反序列化当前JSON对象(例如{“ name”:“ value”})为类型&#39;System.Collections.Generic.List - Cannot deserialize the current JSON object (e.g. {“name”:“value”}) into type 'System.Collections.Generic.List 无法将当前 JSON object(例如 {"name":"value"})反序列化为类型 'System.Collections.Generic.List`1 - Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1 无法将当前JSON对象(例如{“ name”:“ value”})反序列化为类型&#39;System.Collections.Generic.List`1&#39; - Cannot deserialize the current JSON object (e.g. {“name”:“value”}) into type 'System.Collections.Generic.List`1' 无法将当前 JSON object(例如 {“name”:“value”})反序列化为类型需要 JSON 数组(例如 [1,2,3] 才能正确反序列化) - Cannot deserialize the current JSON object (e.g. {“name”:“value”}) into type requires a JSON array (e.g. [1,2,3]) to deserialize correctly 无法反序列化当前的 JSON object(例如 {“name”:“value”} - Cannot deserialize the current JSON object (e.g. {“name”:“value”} 无法反序列化当前JSON对象(例如{“ name”:“ value”}) - Cannot deserialize the current JSON object (e.g. {“name”:“value”}) 无法反序列化当前的 JSON 对象(例如 {“name”:“value”}) - Cannot deserialize the current JSON object (e.g. {“name”:“value”}) 无法将当前JSON数组(例如[1,2,3])反序列化为类型”,因为该类型需要JSON对象(例如{“ name”:“ value”}) - Cannot deserialize the current JSON array (e.g. [1,2,3]) into type '' because the type requires a JSON object (e.g. {“name”:“value”}) JSON.Net - 无法将当前json对象(例如{“name”:“value”})反序列化为类型&#39;system.collections.generic.list`1 - JSON.Net - cannot deserialize the current json object (e.g. {“name”:“value”}) into type 'system.collections.generic.list`1 错误:无法将当前 JSON object(例如 {“name”:“value”})反序列化为类型 'System.Collections.Generic.List`1 - Error: Cannot deserialize the current JSON object (e.g. {“name”:“value”}) into type 'System.Collections.Generic.List`1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM