-1

I m not familiar with python and I want to convert below code from C# to python


 Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse)
    public class StatisticsItem
    {
        public string name { get; set; }
        public string home { get; set; }
        public string away { get; set; }
        public int compareCode { get; set; }
    }

    public class Group
    {
        public string groupName { get; set; }
        public List<StatisticsItem> statisticsItems { get; set; }
    }

    public class Statistic
    {
        public string period { get; set; }
        public List<Group> groups { get; set; }
    }

    public class Root
    {
        public List<Statistic> statistics { get; set; }
    }

the aim is to convert a JSON flat file to an object i m able to do it with C# but I had some difficulty to do it in python

bentalay
  • 21
  • 3
  • if your aim is to convert a json file to an object, you might want to use the json module (json.load function) – tbrugere May 10 '21 at 13:51
  • Can you be more specific as to what the issue is? Please see [ask], [help/on-topic]. – AMC May 10 '21 at 14:57

1 Answers1

-1

You'll want to use __dict__ properties in the class.

See the documentation, as well as a previous Stack Overflow answer for more detail.

Jacob Lee
  • 4,405
  • 2
  • 16
  • 37