0

JSON string:

 { "Result": 
           [
                { "food_photo":255,216,255,224,0,16,74,70,73,70,0,1.....4,255,217],
                  "qty":"12",
                  "time":"23",
                  "cost":null
                }
           ]
   }

My question: how to convert food_photo into a list?

FYI: I use public byte[] food_photo in my class but it shows null when I execute my list.

1 Answer 1

1

Try deserialize food_photo into string and use string.split method

string deserializedFoodPhoto = "255,216,255,224,0,16,74,70,73,70,0,4,255,217";
var photoInList = deserializedFoodPhoto.Split(',').Select(i => byte.Parse(i)).ToList();
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your valuable rply!but i cant get deserialized image array in above json
AFAIK for (de)serialization of JSON objects you can use System.Web.Script.Serialization.JavaScriptSerializer or maybe better System.Runtime.Serialization.Json.DataContractJsonSerializer because your json object is quite deep.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.