Home > OS >  How to desgin class structure while using JsonConvert.DeserializeObject
How to desgin class structure while using JsonConvert.DeserializeObject

Time:07-13

I want to import some data from a json file to a class, it's very clear in PHP but in ASP.net I really don't know how to desgin the class structure while I trying to use JsonConvert.DeserializeObject() to deserialize the json string. Here is my json string:

{
    "video": {
        "path": {
            "source": "d:/videos/",
            "temp": "d:/temp/",
            "dest": "d:/dest/videos/"
        },
        "allowExt": ["avi", "mp4"],
        "bitrate": "1600"
    },
    "photo": {
        "path": {
            "source": "d:/photos/",
            "temp": "d:/temp/",
            "dest": "d:/dest/photoss/"
        },
        "allowExt": ["jpg", "png"],
        "quality": "80"
    }
}

Thank you very much.

CodePudding user response:

There is a lot of online tools for creating models and mappings from json to (almost any language)

The one that suits your needs: https://json2csharp.com/

(Just copy-paste your json to left textarea, click "Convert", be happy)

Another good one is: https://app.quicktype.io/ but it uses Newtonsoft.Json

  • Related