Pentaho

 View Only

 Pentaho javascript code variable object

  • Pentaho
  • Kettle
  • Pentaho
  • Pentaho Data Integration PDI
Manuel munoz's profile image
Manuel munoz posted 08-15-2018 17:28

I am trying to navigate my object with the response of my rest client method, this response is theoretically a JSON Object such that.

{"457": {"2": {"value": "53.8", "timestamp": 1534257707}, "3": {"value": "21.9", "timestamp": 1534257707}, "4": {"value": "255.0", "timestamp": 1534257707}, "21": {"value": "996.0", "timestamp": 1534257707}, "1": {"value": "4.15", " timestamp ": 1534257707}," 17 ": {" value ":" 156.99062499999997 "," timestamp ": 1534257707}," 5 ": {" value ":" 37.667 "," timestamp ": 1534257707}," 6 ": {"value": "28.900000000000002", "timestamp": 1534257707}, "8": {"value": "4.28", "timestamp": 1534257707}, "15": {"value": "0.83", " timestamp ": 1534257707}," 10 ": {" value ":" 19.31 "," timestamp ": 1534257707}," 22 ": {" value ":" 0.0 "," timestamp ": 1534257707}," 23 ": {"value": "0.0", "timestamp": 1534257707}, "24": {"value": "0.0", "timestamp": 1534257707}, "26": {"value": "0.0", " timestamp ": 1534257707}," 653 ": {" value ":" 0.0 "," timestamp ": 1534257707}," 657 ": {" value ":" - 98.0 "," timestamp ": 1518420299}," 43 " : {"value": "11.824136243472958", "timestamp": 1534257707}, "42": {"value": "326.54049999999995", "timestamp": 1534257707}}}

I have created a component in JavaScript to process this data:

This is my code in java script and it works correctly, since I have tried it programming it in another environment.

var key = Object.keys (data) [0]; var finalobj = {};     for (var and in data [key]) {     finalobj [e] = {     type: "float"     , value: parseFloat (data [key] [e] .value)     , metadata: {     timestamp: {     value: parseInt (data [key] [e] .timestamp)     , type: "Integer"     }     }     };     }

The problem is that if I assign to the field it dates the value of my answer like this:

var data = result_ult_dat;

When I throw the code it does not work, but if I manually assign the code to it, if it works correctly, what is the problem ?, I do not understand it, the value of result_ult_dat is the same as the one that I copied, it has to be transforming or something like this:

var data = {"457": {"2": {"value": "53.8", "timestamp": 1534257707}, "3": {"value": "21.9", "timestamp": 1534257707}, " 4 ": {" value ":" 255.0 "," timestamp ": 1534257707}," 21 ": {" value ":" 996.0 "," timestamp ": 1534257707}," 1 ": {" value ":" 4.15 "," timestamp ": 1534257707}," 17 ": {" value ":" 156.99062499999997 "," timestamp ": 1534257707}," 5 ": {" value ":" 37.667 "," timestamp ": 1534257707}," 6 ": {" value ":" 28.900000000000002 "," timestamp ": 1534257707}," 8 ": {" value ":" 4.28 "," timestamp ": 1534257707}," 15 ": {" value ":" 0.83 "," timestamp ": 1534257707}," 10 ": {" value ":" 19.31 "," timestamp ": 1534257707}," 22 ": {" value ":" 0.0 "," timestamp ": 1534257707}," 23 ": {" value ":" 0.0 "," timestamp ": 1534257707}," 24 ": {" value ":" 0.0 "," timestamp ": 1534257707}," 26 ": {" value ":" 0.0 "," timestamp ": 1534257707}," 653 ": {" value ":" 0.0 "," timestamp ": 1534257707}," 657 ": {" value ":" - 98.0 "," timestamp ": 1518420299}, "43": {"value": "11.824136243472958", "timestamp": 1534257707}, "42": {"value": "326.54049999999995", "timestamp": 1534257707}}};

How can I fix the problem.


#Pentaho
#Kettle
#PentahoDataIntegrationPDI
Ricardo Miguel Díaz Razo's profile image
Ricardo Miguel Díaz Razo

Hola Manuel,

Creo contigo puedo escribir en español verdad??

Tengo el presentimiento (casi 100% seguro), que podrías resolver tu problema con el step: JSON INPUT.

Has probado con este STEP?

Que versión de Pentaho estás utilizando?

Data Conversion's profile image
Data Conversion
Data Conversion's profile image
Data Conversion
Attachment  View in library
Data Conversion's profile image
Data Conversion
Data Conversion's profile image
Data Conversion
Data Conversion's profile image
Data Conversion
Raul Flores's profile image
Raul Flores

Estoy con el mismo inconveniente talvez dieron con la solución muchas gracias​