Cannot deserialize the current JSON array (e.g. [1,2,3])

前端 未结 6 1844
遥遥无期
遥遥无期 2020-12-01 12:47

I am trying to read my JSON result.

Here is my RootObject

public class RootObject
{
public int id { get; set; }
public bool is_defau         


        
6条回答
  •  伪装坚强ぢ
    2020-12-01 13:25


    To read more than one json tip (array, attribute) I did the following.


    var jVariable = JsonConvert.DeserializeObject(jsonVariableContent);
    

    change to

    var jVariable = JsonConvert.DeserializeObject >(jsonVariableContent);
    

    Because you cannot see all the bits in the method used in the foreach loop. Example foreach loop

    foreach (jsonDonanimSimple Variable in jVariable)
                    {    
                        debugOutput(jVariable.Id.ToString());
                        debugOutput(jVariable.Header.ToString());
                        debugOutput(jVariable.Content.ToString());
                    }
    

    I also received an error in this loop and changed it as follows.

    foreach (jsonDonanimSimple Variable in jVariable)
                        {    
                            debugOutput(Variable.Id.ToString());
                            debugOutput(Variable.Header.ToString());
                            debugOutput(Variable.Content.ToString());
                        }
    

提交回复
热议问题