XML : How to convert schema into sample document

I am using java Spring Maven plugin and have two schemas JSON schema and XSD from that I want to create sample JSON and XML document.Is there any library is doing the same? or any another way? I googled it but not got any idea in java there are some examples in JavaScript and .NET which is not helpful for this case.

here is json schema

  {  "$schema": "http://json-schema.org/draft-04/schema#",  "type": "object",  "properties": {  "Employee": {    "type": "object",    "properties": {      "empId": {        "type": "integer"      },      "firstName": {        "type": "string"      },      "lastName": {        "type": "string"      },      "title": {        "type": "string"      },      "address": {        "type": "object",        "properties": {          "city": {            "type": "string"          },          "street": {            "type": "string"          },          "zipCode": {            "type": "string"          },          "contactDetails": {            "type": "object",            "properties": {              "mobile": {                "type": "string"              },              "landLine": {                "type": "string"              }            }          }        }      }    },    "required": [      "empId",      "firstName",      "lastName",      "title",      "address"    ]  }  }}    

I want to generate like this

   {   "Employee": {               "empId": 1001,               "firstName": "jonh",               "lastName": "Springer",               "title": "Engineer",               "address": {                          "city": "Mumbai",                          "street": "FadkeStreet",                          "zipCode": "420125",                          "contactDetails": {                                            "mobile": "2564875421",                                            "landLine": "251201546"                           }                }       }    }    

Similar for xsd to xml.

No comments:

Post a Comment