I am looking for ways that I can load an existing JSON schema file into my java application so that I can use it to serialize incoming data into a JSON object to be output to an external application.
The issue is that I can not create a class for the JSON as I want to be able to provide different schema files and have the program then create different objects for use. This way if the outbound data needs to change the only update is in the schema file, and no new classes need to be added to the project. Or if I am outputting data to a different application that has different requirements, I only need to change the schema file.
Here is an example of the schema I will be using:
{
"description": "cashierBalance",
"properties": {
"transactionDate": {
"type": "string",
"description": "The date and the transaction was provided by the Point of Sale system.",
"format": "date-time"
},
"shiftDate": {
"type": "string",
"description": "The date of the cashier work shift for this transaction",
"format": "date-time"
},
"revenueCenter": {
"type": "array",
"description": "An array of all revenue centers worked by the cashier during the referenced shift."
},
"cashValues": {
"type": "object",
"properties": {
"cashSales": {
"type": "string",
"description": "Sum of the sales (including) taxes that occurred in Cash during the shift."
},
"cashReturns": {
"type": "string",
"description": "Sum of the cash returned (e.g. change)"
},
"cashDrops": {
"type": "string",
"description": "Sum of the cash taken from cash drawer and placed in a drop box or safe."
},
"cashPayout": {
"type": "string",
"description": "Sum of cash removed from the cash drawer, exluding cashReturns or cashTips, during the shift."
},
"cashPayin": {
"type": "string",
"description": "Sum of cash put into the cash drawer after initial opening."
},
"cashTips": {
"type": "string",
"description": "Sum of cash paid out from the drawer for tips."
},
"cashTotal": {
"type": "string",
"description": "Total amount of cash in the drawer at the close of the shift."
},
"cashCurrency": {
"type": "string",
"description": "The currency of the cash for the elements in this object."
}
},
"required": [
"cashSales",
"cashReturns",
"cashTotal",
"cashCurrency"
]
},
"cashierInfo": {
"type": "object",
"properties": {
"cashierID": {
"type": "string",
"description": "The identifier of the Cashier."
},
"cashierName": {
"type": "string",
"description": "The name of the Cashier."
}
},
"required": [
"cashierID",
"cashierName"
]
}
},
"required": [
"transactionDate",
"shiftDate",
"revenueCenter",
"cashValues",
"cashierInfo"
]
}