0

I am able to set up an array for a class when each component in the array has a name (in this case progname). The JSON looks like this

"document_prg":{
   "data":[
      {
         "progname":"prog1"
      }
   ]
},

The class is set up as follows

public Programs document_prg { get; set; }

public class Programs
{
    public List<datas> data { get; set; } 

    public class datas
    {
        public string progname { get; set; }
    }
}        

However when the elements in the array don't have a name, I am having difficulty. In the example below, the data element is the word regional. But it has no name. Can anyone provide some help on how to set up the class for the JSON String below:

"document_type":[
   "Regional"
],
Peter Csala
  • 17,736
  • 16
  • 35
  • 75
  • 1
    `public List document_type { get; set; }` See [How to auto-generate a C# class file from a JSON string](https://stackoverflow.com/q/21611674/3744182) for tools you can use to auto-generate classes from JSON samples. – dbc May 27 '21 at 04:55
  • Deserializing a JSON array of strings to a `List` property is the same answer as [this answer](https://stackoverflow.com/a/63665334/3744182) to [JSON DeserializeObject that has a list of strings](https://stackoverflow.com/q/63665288/3744182). Closing as a duplicate. – dbc May 27 '21 at 14:22

0 Answers0