Validation of DSTU2 resources

We are using DSTU2 compliant resource in our code, and we use json structure as resorce representation,
For DSTU2 compliant resources json schema are not available for validation from FHIR.

Since we also want to do validation in test environment we do not want to access any online service like(HAPI) etc.

Do you have any suggestions on how can we achieve same?

The FHIR validator tool supports validating FHIR DSTU2 instances: http://build.fhir.org/validation.html#jar

in the tool it is mentioned that it does not support json validation , i am looking for json validation

The validator will validate STU2 JSON instances. It just doesn’t use JSON schema.

i tried using the xml validator tool available here
But i get error-

Exception in thread "main" com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 5 path $
        at com.google.gson.JsonParser.parse(JsonParser.java:65)
        at com.google.gson.JsonParser.parse(JsonParser.java:45)
        at org.hl7.fhir.dstu2.validation.ValidationEngine.processJson(ValidationEngine.java:239)
        at org.hl7.fhir.dstu2.validation.ValidationEngine.process(ValidationEngine.java:129)
        at org.hl7.fhir.dstu2.validation.Validator.process(Validator.java:198)
        at org.hl7.fhir.dstu2.validation.Validator.main(Validator.java:120)
Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 5 path $
        at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1572)
        at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1421)
        at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:544)
        at com.google.gson.stream.JsonReader.peek(JsonReader.java:427)
        at com.google.gson.JsonParser.parse(JsonParser.java:60)
        ... 5 more

for below json, any insights on what is wrong -

{  
   "resourceType":"DiagnosticReport",
   "meta":{  
      "versionId":"spark3",
      "lastUpdated":"2017-09-29T05:40:08.365+00:00"
   },
   "text":{  
      "status":"generated",
      "div":"<div xmlns=\"http://www.w3.org/1999/xhtml\">\r\n  <h2>DXA BONE DENSITOMETRY</h2>\r\n  <table>\r\n    <tr>\r\n      <td>NAME</td>\r\n      <td>XXXXXXX</td>\r\n    </tr>\r\n    <tr>\r\n      <td>DOB</td>\r\n      <td>10/02/1974</td>\r\n    </tr>\r\n    <tr>\r\n      <td>REFERRING DR</td>\r\n      <td>Smith, Jane</td>\r\n    </tr>\r\n    <tr>\r\n      <td>INDICATIONS</td>\r\n      <td>Early menopause on estrogen levels. No period  for 18 months</td>\r\n    </tr>\r\n    <tr>\r\n      <td>PROCEDURE</td>\r\n      <td>Dual energy x-ray absorptiometry (DEXA)</td>\r\n    </tr>\r\n  </table>\r\n  <h3>Bone Mineral Density</h3>\r\n  <table>\r\n    <tr>\r\n      <td>Scan Type</td>\r\n      <td>Region</td>\r\n      <td>Measured</td>\r\n      <td>Age</td>\r\n      <td>BMD</td>\r\n      <td>T-Score</td>\r\n      <td>Z-Score</td>\r\n      <td>?BMD(g/cm2)</td>\r\n      <td>?BMD(%)</td>\r\n    </tr>\r\n    <tr>\r\n      <td>AP Spine</td>\r\n      <td>L1-L4</td>\r\n      <td>17/06/2008</td>\r\n      <td>34.4</td>\r\n      <td>1.148 g/cm²</td>\r\n      <td>-0.4</td>\r\n      <td>-0.5</td>\r\n      <td>-</td>\r\n      <td>-</td>\r\n    </tr>\r\n    <tr>\r\n      <td>Left Femur</td>\r\n      <td>Neck</td>\r\n      <td>17/06/2008</td>\r\n      <td>34.4</td>\r\n      <td>0.891 g/cm²</td>\r\n      <td>-1.0</td>\r\n      <td>-0.9</td>\r\n      <td>-</td>\r\n      <td>-</td>\r\n    </tr>\r\n    <tr>\r\n      <td>Left Femur</td>\r\n      <td>Total</td>\r\n      <td>17/06/2008</td>\r\n      <td>34.4</td>\r\n      <td>0.887 g/cm²</td>\r\n      <td>-1.2</td>\r\n      <td>-1.3</td>\r\n      <td>-</td>\r\n      <td>-</td>\r\n    </tr>\r\n    <tr>\r\n      <td>Right Femur</td>\r\n      <td>Neck</td>\r\n      <td>17/06/2008</td>\r\n      <td>34.4</td>\r\n      <td>0.885 g/cm²</td>\r\n      <td>-1.0</td>\r\n      <td>-1.0</td>\r\n      <td>-</td>\r\n      <td>-</td>\r\n    </tr>\r\n    <tr>\r\n      <td>Right Femur</td>\r\n      <td>Total</td>\r\n      <td>17/06/2008</td>\r\n      <td>34.4</td>\r\n      <td>0.867 g/cm²</td>\r\n      <td>-1.4</td>\r\n      <td>-1.4</td>\r\n      <td>-</td>\r\n      <td>-</td>\r\n    </tr>\r\n  </table>\r\n  <p>Assessment:</p>\r\n  <ul>\r\n    <li>The Spine L1-L4 BMD is normal.</li>\r\n    <li>The Left Femur Neck BMD is in the osteopenic range. Relative fracture risk is about 2.</li>\r\n    <li>The Left Femur Total BMD is in the osteopenic range. Relative fracture risk is about 2.</li>\r\n    <li>The Right Femur Neck BMD is in the osteopenic range. Relative fracture risk is about 2.</li>\r\n    <li>The Right Femur Total BMD is in the osteopenic range. Relative fracture risk is about 2.</li>\r\n  </ul>\r\n  <p>\r\n    <b>COMMENT</b>\r\n  </p>\r\n  <p>Osteopenia on measured BMD. The estimated 10-year probability of fracture based on present age, gender and measured BMD is less than 10%. This absolute fracture risk remains low. A follow-up assessment may be considered in 2 to 3 years to monitor the trend in BMD.</p>\r\n  <p>Thank you for your referral.  Dr Peter Ng  17/06/2008</p>\r\n  <pre>\r\nNote:\r\nWHO classification of osteoporosis (WHO Technical Report Series 1994: 843)\r\n- Normal: T-score equal to -1.0 s.d. or higher\r\n- Osteopenia: T-score  between -1.0 and -2.5 s.d.\r\n- Osteoporosis: T-score equal to -2.5 s.d. or lower\r\n- Severe/Established osteoporosis: Osteoporosis with one or more fragility fracture.\r\nT-score: The number of s.d. from the mean BMD for a gender-matched young adult population.\r\nZ-score: The number of s.d. from the mean BMD for an age-, weight- and gender-matched population.\r\nReference for 10-year probability of fracture risk: Kanis JA, Johnell O, Oden A, Dawson A,  De Laet C, Jonsson B. Ten year probabilities of osteoporotic fractures according to BMD and diagnostic thresholds. Osteoporos.Int. 2001;12(12):989-995.\r\nGE LUNAR PRODIGY DENSITOMETER\r\n</pre>\r\n</div>"
   },
   "contained":[  
      {  
         "resourceType":"Observation",
         "id":"r1",
         "status":"final",
         "code":{  
            "coding":[  
               {  
                  "system":"http://loinc.org",
                  "code":"24701-5",
                  "display":"Femur DXA Bone density"
               }
            ]
         },
         "subject":{  
            "reference":"Patient/pat2"
         },
         "performer":[  
            {  
               "reference":"Organization/1832473e-2fe0-452d-abe9-3cdb9879522f",
               "display":"Acme Imaging Diagnostics"
            }
         ],
         "valueQuantity":{  
            "value":0.887,
            "unit":"g/cm²",
            "system":"http://unitsofmeasure.org",
            "code":"g/cm-2"
         },
         "bodySite":{  
            "coding":[  
               {  
                  "system":"http://snomed.info/sct",
                  "code":"71341001:272741003=7771000"
               }
            ]
         }
      }
   ],
   "status":"final",
   "code":{  
      "coding":[  
         {  
            "system":"http://loinc.org/",
            "code":"38269-7"
         }
      ],
      "text":"DXA BONE DENSITOMETRY"
   },
   "subject":{  
      "reference":"http://spark.furore.com/fhir/Patient/pat2"
   },
   "effectiveDateTime":"2008-06-17",
   "issued":"2008-06-18T09:23:00+10:00",
   "performer":{  
      "reference":"http://spark.furore.com/fhir/Organization/1832473e-2fe0-452d-abe9-3cdb9879522f",
      "display":"Acme Imaging Diagnostics"
   },
   "result":[  
      {  
         "reference":"#r1"
      }
   ],
   "codedDiagnosis":[  
      {  
         "coding":[  
            {  
               "system":"http://snomed.info/sct",
               "code":"391040000",
               "display":"At risk of osteoporotic fracture"
            }
         ]
      }
   ]
}

You should always use the “current” version of the validator. The most recent version can be found here:
http://build.fhir.org/downloads.html