0

Is there any way to generate vb classes from jsonschema files like we can generate classes from wsdls and xsds using wsdl.exe in one go.

I don't want to use Edit > Paste special > paste JSON as class feature of Visual Studio because I tried for one file and it did not give me the result I am expecting and also there are about 15 schema files so want a generic way.

On using Edit > Paste special > paste JSON as class feature of Visual Studio, The schema have is:

{
  "title": "MyObject",
  "type": "object",
  "properties": {
    "description": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "id": {
      "type": "string"
    }
  },
  "required": [ "id", "description", "name" ]
} 

The generated classes:

Public Class Rootobject
    Public Property title As String
    Public Property type As String
    Public Property properties As Properties
    Public Property required() As String
End Class

Public Class Properties
    Public Property description As Description
    Public Property name As Name
    Public Property id As Id
End Class

Public Class Description
    Public Property type As String
End Class

Public Class Name
    Public Property type As String
End Class

Public Class Id
    Public Property type As String
End Class
Wini
  • 39
  • 5
  • [NJsonSchema for .NET](https://github.com/RicoSuter/NJsonSchema) – Jimi Jun 29 '20 at 13:11
  • Did you try any of the other answers from [Generate C# classes from JSON Schema](https://stackoverflow.com/q/6358745/3744182)? See also [this comment](https://stackoverflow.com/questions/6358745/generate-c-sharp-classes-from-json-schema#comment109586974_6358745). You wrote, *i tried for one file and it did not give me the result I am expecting* - Then please share a [mcve]. Without the schema that causes the problem, this question may be closed for being a [recommendation request](https://meta.stackoverflow.com/q/251134) or lacking debugging details, and so off topic. – dbc Jun 29 '20 at 15:05
  • 1
    Looks like it is creating classes to *deserialize the schema itself* which is of course not what you want. https://app.quicktype.io/ can generate plausible c# classes, see https://app.quicktype.io/?share=ORMlL5Y7Vs2uhTHBdY7U. No option for vb.net though. [NJsonSchema for .NET](https://github.com/RicoSuter/NJsonSchema) also is not documented to work for vb.net. You might still give those tools a try and then run the results through a vb.net => c# translator. – dbc Jun 29 '20 at 20:27

0 Answers0