jsonata module error in node.js

Is jsonata module supported in Apigee Node js Module ? I have a requirement to use jsonata module in node.js. Atttached error (jsonataerror.txt) which i received while executing node.js. Can you please help me to resolve this ?Note: I have installed jsonata module properly using management API. I have tried un/re deployed proxies but still error exists.

Attached my sample proxy which is using jsonata.samplejsonata.zip

I’ve just tried and ran into same issue. It’s possible that’s an incompatibility due to Trireme running on 0.10.x. I also slightly modified your code to use Express. Any clue might be missing @Jeremy Whitlock?

console.log('node.js application starting...');
var jsonata = require("jsonata");
var express = require('express');
var app = express();

app.get('/', function (req, res) {
  var data = {
    example: [{
        value: 4
      },
      {
        value: 7
      },
      {
        value: 13
      }
    ]
  };
  var expression = jsonata("$sum(example.value)");
  var result = expression.evaluate(data); // returns 24
  res.send(JSON.stringify(result));
})

var server = app.listen(3000, function () {
  var host = server.address().address
  var port = server.address().port
  console.log('Example app listening at http://%s:%s', host, port)
});

Hi Diego, Thanks for trying the poc. Any updates on the error on how to resolve it ?

Thanks,

-Suganya

Their package.json says it requires node 4.4 or greater, which means it will not work in Trieme.

https://github.com/jsonata-js/jsonata/blob/master/package.json

https://docs.npmjs.com/files/package.json#engines

https://github.com/apigee/trireme

Thanks williamking !!

Any plans to get the upgraded version in Edge platform ? I see in below post , Apigee was working on container-based solution to get the upgraded node version.

https://community.apigee.com/questions/23770/upgrading-edges-version-of-node.html

Thanks,

-Suganya

JSONata has a transpiled version for running in ES5 environments. Use the following require statement:


var jsonata = require(“jsonata/jsonata-es5”);


This should work with node v0.10.x.