title: Lua json schema validator
body: <p>I have been looking for over 4 days now but I havent been able to find much support on code for lua based json schema compiler. Mainly I have been dealing with </p>
  
  <ul>
  <li>ljsonschema (<a href="https://github.com/jdesgats/ljsonschema" rel="nofollow noreferrer">https://github.com/jdesgats/ljsonschema</a>)</li>
  <li>rjson (<a href="https://luarocks.org/modules/romaboy/rjson" rel="nofollow noreferrer">https://luarocks.org/modules/romaboy/rjson</a>)</li>
  </ul>
  
  <p>But either of the above have not been straight forward to use. </p>
  
  <p>After dealing with issues on the <code>luarocks</code>, I finally got <code>ljsonschema</code> working but the JSON syntax looks different than normal JSON structure - For ex: equals in place of semi colon, no double quotes for key names etc. </p>
  
  <p>ljsonschema supports </p>
  
  <pre><code>{ type = 'object', properties = {
  foo = { type = 'string' },
  bar = { type = 'number' },},}
  </code></pre>
  
  <p>I require : </p>
  
  <pre><code>{ "type" : "object",
  "properties" : {
  "foo" : { "type" : "string" },
  "bar" : { "type" : "number" }}}
  </code></pre>
  
  <p>With <code>rjson</code> there is an issue with the installation location itself. Though the installation goes fine, it is never able to find the .so file while running the lua code. Plus there is not much development support that I could find.</p>
  
  <p>Please help point in the right direction, in case I am missing something. 
  I have the json schema &amp; a sample json, I just need a lua code to help write a program around it. </p>
  
  <p>This is to write a custom JSON Validation Plugin for Kong CE.</p>
  
  <p><strong>UPDATED:</strong>
  I would like the below code to work with ljsonschema: </p>
  
  <pre><code>local jsonschema = require 'jsonschema'
  
   -- Note: do cache the result of schema compilation as this is a quite
   -- expensive process
   local myvalidator = jsonschema.generate_validator{
     "type" : "object",
     "properties" : {
     "foo" : { "type" : "string" },
     "bar" : { "type" : "number" }
   }
  }
  
  print(myvalidator { "foo":"hello", "bar":42 })
  </code></pre>
  
  <p>But I get the error : <code>'}' expected (to close '{' at line 5) near ':'</code></p>