HEX
Server: nginx/1.24.0
System: Linux nowruzgan 6.8.0-57-generic #59-Ubuntu SMP PREEMPT_DYNAMIC Sat Mar 15 17:40:59 UTC 2025 x86_64
User: babak (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/dev/nowruzgan/rest/node_modules/machinepack-json/machines/parse.js
module.exports = {


  friendlyName: 'Parse JSON string',


  description: 'Parse data from a JSON-encoded string.',


  extendedDescription: '',


  sync: true,


  cacheable: true,


  inputs: {

    json: {
      friendlyName: 'JSON string',
      description: 'The JSON string to parse',
      example: '...{"some json": "like this"}...',
      required: true
    },

    schema: {
      friendlyName: 'Expected schema',
      description: 'A representative example (RTTC exemplar) of what the resulting data should look like.',
      moreInfoUrl: 'http://github.com/node-machine/rttc',
      example: '*',
      constant: true,
      isExemplar: true
    }

  },


  exits: {

    couldNotParse: {
      friendlyName: 'could not parse',
      description: 'Could not parse provided string- must be a valid JSON string.',
      extendedDescription: 'Oftentimes this error is a result of not using double-quotes.  Refer to the official JSON specification at http://www.json.org/ for more information.'
    },

    success: {
      friendlyName: 'then',
      description: 'Done.',
      like: 'schema'
    }

  },


  fn: function(inputs, exits) {

    var parsedJson;
    try {
      parsedJson = JSON.parse(inputs.json);
    }
    catch (e){
      return exits.couldNotParse(e);
    }
    return exits.success(parsedJson);
  }

};