Create Model from JSON

In this case I am going to use the Hotel List from Amadeus for Developers.  Either directly from Amadeus, or via Insomnia (totally unnecessary!), copy the json data created to the clipboard.

Open https://jsoneditoronline.org

  • Paste the json code into the left-hand pane
  • Not necessary, but if select to copy to right-hand pane can see data in 'tree' view. (Also possible by selecting 'Tree' from top of left-hand pane.)
  • Collapse a few records in left-hand pane (little arrow in margin)
  • Copy one collapsed record (curly bracket to curly bracket, but not the comma after the closing curly bracket)
  • Select the whole text in left-hand pane and delete
  • Paste back the one record copied above
  • Delete any fields not required
  • Copy all the remaining json in the left-hand column

Open https://app.quicktype.io

  • Paste the json into the left-hand pane
  • Edit the title above the code to something suitable, this will be used to name the top-level model.
  • Change the language in the right-hand bar to C#
  • Now change:
    • 'Serialization' to 'System Text Json'
    • 'Output Features' to 'Attributes Only'
  • Copy the C# code