lib/impl/importForms/inputValidator.js
function validateJSonStructure(filePath, cb) {
  fs.readFile(filePath, function(err, data) {
    if (err) {
      return cb(err);
    }

    try {
      var jsonObject = JSON.parse(data);
      cb(null, jsonObject);
    } catch (e) {
      cb('Invalid JSON file: ' + path.basename(filePath));
    }
  });
}
function validateJSonStructure(filePath, cb) {
  fs.readFile(filePath, function(err, data) {
    if (err) {
      return cb(err);
    }

    try {
      var jsonObject = JSON.parse(data);
      cb(null, jsonObject);
    } catch (e) {
      cb('Invalid JSON file: ' + path.basename(filePath));
    }
  });
}
function validateJSonStructure ( filePath , cb ) { fs . readFile ( filePath , function ( err , data ) { if ( err ) { return cb ( err ) ; } try { var jsonObject = JSON . parse ( data ) ; cb ( null , jsonObject ) ; } catch ( e ) { cb ( 'Invalid JSON file: ' + path . basename ( filePath ) ) ; } } ) ; }
Checks that the received file is a well formed json
@param {string} filePath path to the JSon file
@param {function} cb callback
Checks that the received file is a well formed json