Skip to content

[Bug]: Javascript transform has a 'Get variables' button that raises errors when it should not #3403

Description

@Mattang-Dan

Apache Hop version?

2.7

Java version?

openjdk 11.0.19 2023-04-18 LTS OpenJDK Runtime Environment Microsoft-7621296 (build 11.0.19+7-LTS) OpenJDK 64-Bit Server VM Microsoft-7621296 (build 11.0.19+7-LTS, mixed mode)

Operating system

Windows

What happened?

The JavaScript button 'Get Variables' seems to be buggy. Several times I changed the Javascript code below and re-run and it does not always work, and sometimes it does. The script below is valid, but when clicking 'Get variables" I get an error about the token which is a valid data row stream field from a JSON input transform that I am referencing. I had to manually add the field 'flattened_json' to get it to work.

Error is:
HopException:
General error executing script:
SyntaxError: Unexpected token: t (script#9)

Root cause: EcmaError: SyntaxError: Unexpected token: t (script#9)

//Script to flatten JSON keys for Hop

//var input_json = {
//    "c-102": "AIDS Healthcare",
//    "c-105": "AIDS Healthcare Direct",
//    "c-75": "Allied Physicians (ALIP)",
//    "c-59": "Asheville Endocrinology"};

var input_json = JSON.parse(tabsFlat);
var output_json = [];

for (var key in input_json) {
    var value = input_json[key];
    output_json.push({
        field1: key,
        field2: value
    });
}

var flattened_json = JSON.stringify(output_json);

Issue Priority

Priority: 3

Issue Component

Component: Hop Gui

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions