<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Is there JSON model validation in Splunk? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-JSON-model-validation-in-Splunk/m-p/500340#M85247</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="{
\"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\"
}"
| spath
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What's your expected result?&lt;BR /&gt;
&lt;CODE&gt;spath&lt;/CODE&gt; is enough?&lt;/P&gt;</description>
    <pubDate>Tue, 04 Feb 2020 13:14:44 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-02-04T13:14:44Z</dc:date>
    <item>
      <title>Is there JSON model validation in Splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-JSON-model-validation-in-Splunk/m-p/500339#M85246</link>
      <description>&lt;P&gt;Hello, I have complex json being written to splunk and want to do model file validation , what is the best way to do this in splunk for each of the json data written to spunk ? apart from checking json matches model structure, want to check for mandatory values for some fields and format matching for some fields, can this be done inside splunk ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
"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"
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Feb 2020 00:58:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-JSON-model-validation-in-Splunk/m-p/500339#M85246</guid>
      <dc:creator>msrama5</dc:creator>
      <dc:date>2020-02-04T00:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is there JSON model validation in Splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-JSON-model-validation-in-Splunk/m-p/500340#M85247</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="{
\"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\"
}"
| spath
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What's your expected result?&lt;BR /&gt;
&lt;CODE&gt;spath&lt;/CODE&gt; is enough?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2020 13:14:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-JSON-model-validation-in-Splunk/m-p/500340#M85247</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-04T13:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: Is there JSON model validation in Splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-JSON-model-validation-in-Splunk/m-p/500341#M85248</link>
      <description>&lt;P&gt;I want to compare with json model file which has fieldnames and datatypes for each field , what I want to check  is  field names structures are aligned and data types mismatches don't exist comparing json model file with actual json data at run time and filter json requests which does match the model file&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 06:51:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-JSON-model-validation-in-Splunk/m-p/500341#M85248</guid>
      <dc:creator>msrama5</dc:creator>
      <dc:date>2020-02-11T06:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Is there JSON model validation in Splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-JSON-model-validation-in-Splunk/m-p/500342#M85249</link>
      <description>&lt;P&gt;You can create a new kvstore collection on search head and enforce type checking in collections.conf in an app.&lt;/P&gt;

&lt;P&gt;collections.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[test]
enforceTypes = true
field.TestTransaction.OrderEntryType = number
field.TestTransaction.Number = number
field.TestTransaction.CloseDate = time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then use REST API to write this data to collection, if field values in json doesn't match  data type then insertion will fail and response is returned with an error.&lt;/P&gt;

&lt;P&gt;curl -kv -u admin "&lt;A href="https://localhost:8089/servicesNS/nobody/APP_NAME/storage/collections/data/test"&gt;https://localhost:8089/servicesNS/nobody/APP_NAME/storage/collections/data/test&lt;/A&gt;" -H 'Content-Type: application/json' -d '{"TestTransaction":{"OrderEntryType":"&lt;STRONG&gt;test&lt;/STRONG&gt;","Number":69909696,"CloseDate":"2020-02-03T15:31:38.1260000Z"}}'&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;*&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;response&amp;gt;
  &amp;lt;messages&amp;gt;
    &amp;lt;msg type="ERROR"&amp;gt;JSON in the request is invalid. (Failed to convert key='OrderEntryType' with value='test' to type '1')&amp;lt;/msg&amp;gt;
  &amp;lt;/messages&amp;gt;
&amp;lt;/response&amp;gt;*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Feb 2020 07:34:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-JSON-model-validation-in-Splunk/m-p/500342#M85249</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-02-11T07:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: Is there JSON model validation in Splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-JSON-model-validation-in-Splunk/m-p/500343#M85250</link>
      <description>&lt;P&gt;Thanks, I got the field validation, I also need to validate json data structure is not out of order (or) some fields missing and corrupted comparing to original json model template, we have seen this happen where a bad json with fields out of order would come at run time and need to alert by comparing with original model template and write requests that are corrupted, can the json data be compared with model template  inside splunk ? &lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2020 06:18:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-JSON-model-validation-in-Splunk/m-p/500343#M85250</guid>
      <dc:creator>msrama5</dc:creator>
      <dc:date>2020-02-12T06:18:02Z</dc:date>
    </item>
  </channel>
</rss>

