Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: trimming changes output of parsed JSON attribute #4960

Closed
gmitter-ef opened this issue Feb 28, 2025 · 2 comments · Fixed by #4970
Closed

[Bug]: trimming changes output of parsed JSON attribute #4960

gmitter-ef opened this issue Feb 28, 2025 · 2 comments · Fixed by #4970
Assignees
Labels
Milestone

Comments

@gmitter-ef
Copy link

gmitter-ef commented Feb 28, 2025

Apache Hop version?

2.12.0

Java version?

OpenJDK 17

Operating system

Windows

What happened?

When using "Load file content in memory" to read a JSON file and a "JavaScript" transform to parse it, changing "Trim type" from "None" to any other value (i.e. "left", "right" or "both" in the "Fields" tab of "Load file content in memory" transform) changes the output of a (whitespace-less!) value of a JSON attribute.

How to reproduce:

  • copy the two files to default project (the hpl file is zipped as hpl files cannot be uploaded)
  • preview "JavaScript" transform

If you change back "Trim type" to "none" everything is ok (last image).

Note that the difference in output depending on trim type is also the case when the metric attribute is nested inside a more complex JSON structure.
File content's data type "String" and "JSON" behave the same. Encoding set to UTF8, for both the stream field and the file written from disk.
Note that the wrong output also occurs even when "°" characer is not the first or last character in the string.
Using "JSON input" directly to read and parse the jSON does not show a difference in output when changing the trim type.
Seems to be a problem of "Load file content in memory"-"JavaScript" combination.

Issue Priority

Priority: 3

Issue Component

Component: Hop Gui, Component: Transforms

Image

Image

trim_behaviour.json

trim_behaviour.hpl.zip

Image

@gmitter-ef
Copy link
Author

Did a little more testing:
seems to be an issue of "Load file content in memory" transform:
when "file_content" is read as String, and not sent to a "Java Script" transform but to a "JSON input", then the issue appears.
Using JSON input to directly read the file does not show the issue.

@sramazzina sramazzina self-assigned this Mar 3, 2025
@sramazzina
Copy link
Contributor

Issue confirmed as a bug

@sramazzina sramazzina mentioned this issue Mar 3, 2025
5 tasks
@hansva hansva removed the bug label Mar 12, 2025
@hansva hansva closed this as completed in 306fb32 Mar 18, 2025
hansva added a commit that referenced this issue Mar 18, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix #4960
@hansva hansva added this to the 2.13 milestone Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants