Getting Data In

How to do XSD schema validation on JSON data

msrama5
Explorer

Hello, I have complex JSON being written to Splunk and want to do XSD schema validation on the JSON, this is to ensure that JSON is not corrupted for some fields missing or out of order, what is the best way to do this ?

Below is the JSON request which has XSD schema and validation needs done:

 {
     "TestTransaction":{
     "OrderEntryType":141,
     "Number":69909696,
     "CloseDate":"2020-02-03T15:31:38.1260000Z",
     "ab":"test",
     "Trans":[
     {
     "Amt":5.45,
     "Desc":"test card",
     "Id":"961071022758064128",
     "Number":7777207236838910,
     "ab":"test",
     "$type":"test"
     }
     ],
     "TotalAmt":5.45,
     "SubAmount":4.95,
     "TaxAmount":0.5,
     "DiscountAmount":0.0,
     "Header":{
     "ServiceType":null,
     "RequestDate":"2020-02-03T15:31:38.1260000Z",
     "$type":"Header"
     },
     "Preparation":"ConsOutOfStore",
     "Details":{
     "Discounts":[
     ],
     "Items":[
     {
     "Qty":1.0,
     "Sku":null,
     "Price":4.45,
     "Discounts":[
     ],
     "OverrideDescription":null,
     "OverridePrice":null,
     "Suffix":null,
     "ChildItems":[
     {
     "Qty":1.0,
     "Sku":null,
     "Price":0.0,
     "Discounts":null,
     "IsRefunded":false,
     "IsTaxed":false,
     "Summary":{
     "TotalPrice":4.95,
     "DiscountAmount":0,
     "SubtotalAmount":4.95,
     "$type":"testSummary"
     },
     "$type":"testItem"
     }
     ],
     "Taxes":[
     {
     "Name":"Sales Tax",
     "Amount":50,
     "$type":"testTax"
     }
     ],
     "ReceiptLines":[
     ],
     "Delivery":null,
     "$type":"testDetails"
     },
     "$type":"trans"
     },
     "RequestId":"test",
     "MessageId":"test",
     "$type":"testTransaction"
     }
0 Karma
Get Updates on the Splunk Community!

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Index This | What goes away as soon as you talk about it?

May 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...

What's New in Splunk Observability Cloud and Splunk AppDynamics - May 2025

This month, we’re delivering several new innovations in Splunk Observability Cloud and Splunk AppDynamics ...