This is an automated email from the ASF dual-hosted git repository.

bamaer pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new 2b72cda2a7 JSON output keeps all rows in memory, and JSON input and 
JSON normali… (#9450)
2b72cda2a7 is described below

commit 2b72cda2a72efeacecb8bf6ed4e880253cc22bd1
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Sat Nov 14 13:21:37 2026 +0100

    JSON output keeps all rows in memory, and JSON input and JSON normali… 
(#9450)
    
    * JSON output keeps all rows in memory, and JSON input and JSON normalize 
throw an exception for every number, fxes #9448
    
    * fix remarks
    
    ---------
    
    Co-authored-by: Bart Maertens <[email protected]>
---
 .../ROOT/pages/pipeline/transforms/jsoninput.adoc  |   6 +
 .../pipeline/transforms/jsonnormalizeinput.adoc    |   6 +
 .../json/0009-json-normalize-root-array.hpl        |   2 +-
 ...rray.hpl => 0020-json-number-decimal-comma.hpl} | 149 ++++++++----
 .../golden-json-number-decimal-comma-input.csv     |   5 +
 .../golden-json-number-decimal-comma-normalize.csv |   5 +
 .../json/main-0020-json-number-decimal-comma.hwf   |  78 +++++++
 .../golden-json-number-decimal-comma-input.json    |  25 +++
 ...golden-json-number-decimal-comma-normalize.json |  25 +++
 .../0020-json-number-decimal-comma UNIT.json       |  49 ++++
 .../resources/json-number-decimal-comma-it.json    |  20 ++
 .../jsoninput/reader/RowOutputConverter.java       |  93 ++++++++
 .../jsonnormalize/JsonNormalizeInput.java          |   6 +-
 .../pipeline/transforms/jsonoutput/JsonOutput.java | 112 +++++----
 .../transforms/jsonoutput/JsonOutputData.java      |  27 ++-
 .../transforms/jsonoutput/JsonRowsText.java        |  96 ++++++++
 .../reader/RowOutputConverterNumberTest.java       | 249 +++++++++++++++++++++
 .../JsonNormalizeSamplePipelinesTest.java          |  46 ++++
 .../transforms/jsonoutput/JsonOutputTest.java      |   7 +-
 .../transforms/jsonoutput/JsonRowsTextTest.java    | 153 +++++++++++++
 20 files changed, 1061 insertions(+), 98 deletions(-)

diff --git 
a/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/jsoninput.adoc 
b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/jsoninput.adoc
index 193c399f32..4225788abb 100644
--- a/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/jsoninput.adoc
+++ b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/jsoninput.adoc
@@ -155,6 +155,12 @@ You can search for a field name by entering the field name 
in the Search box.
 
 Click Select fields from snippet button and paste the entire JSON text and it 
will populate the Name, Path, Type columns in the Fields tab. Example: This is 
useful when copying JSON from a previous REST client’s output result.
 
+*Numbers*
+
+A JSON number, such as `199.5` or `12`, is read as the number it is into an 
Integer, Number or BigNumber field. The Format, Decimal and Group of the field 
are not used for it: they say how the field is shown, and how a number that the 
JSON holds as a string, such as `"1.234,50"`, is read. A number with decimals 
read into an Integer field loses its fraction.
+
+NOTE: Before Hop 2.21, some JSON numbers were read with the Decimal and Group 
of the field. Where the comma is the decimal symbol, set on the field or by the 
locale, `199.5` could come out as `1995`.
+
 *Dates and Timestamps*
 
 For Hop types of Date and Timestamp, use the Format column to specify the 
incoming format. E.g. for Date: yyyy-MM-dd. You can either select a format from 
the dropdown or enter format text directly.
diff --git 
a/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/jsonnormalizeinput.adoc
 
b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/jsonnormalizeinput.adoc
index 50b68ea857..ee9a1a76a1 100644
--- 
a/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/jsonnormalizeinput.adoc
+++ 
b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/jsonnormalizeinput.adoc
@@ -124,6 +124,12 @@ You can search for a field name by entering it in the 
Search box.
 
 Click *Select fields from snippet* and paste JSON text—typically *one 
representative object* (one element of the array your **Record JsonPath** 
selects)—to populate the *Name*, *Path*, and *Type* columns in the Fields tab. 
This helps discover flattened paths after your Content-tab settings (separator, 
depth, array handling) are applied.
 
+*Numbers*
+
+A JSON number, such as `199.5` or `12`, is read as the number it is into an 
Integer, Number or BigNumber field. The Format, Decimal and Group of the field 
are not used for it: they say how the field is shown, and how a number that the 
JSON holds as a string, such as `"1.234,50"`, is read. A number with decimals 
read into an Integer field loses its fraction.
+
+NOTE: Before Hop 2.21, every JSON number was read with the Format, Decimal and 
Group of the field. Where the comma is the decimal symbol, set on the field or 
by the locale, `199.5` came out as `1995`.
+
 *Dates and timestamps*
 
 For Hop types of *Date* and *Timestamp*, use the *Format* column to specify 
the incoming format. For example, for Date: `yyyy-MM-dd`. You can select a 
format from the dropdown or enter format text directly.
diff --git a/integration-tests/json/0009-json-normalize-root-array.hpl 
b/integration-tests/json/0009-json-normalize-root-array.hpl
index ab497e9a57..24d9b1c67b 100644
--- a/integration-tests/json/0009-json-normalize-root-array.hpl
+++ b/integration-tests/json/0009-json-normalize-root-array.hpl
@@ -64,7 +64,7 @@ limitations under the License.
     <IsAFile>N</IsAFile>
     <addresultfile>N</addresultfile>
     <IsIgnoreEmptyFile>N</IsIgnoreEmptyFile>
-    <doNotFailIfNoFile>Y</doNotFailIfNoFile>
+    <doNotFailIfNoFile>N</doNotFailIfNoFile>
     <readurl>N</readurl>
     <removeSourceField>N</removeSourceField>
     <recordPath>$.events[*]</recordPath>
diff --git a/integration-tests/json/0009-json-normalize-root-array.hpl 
b/integration-tests/json/0020-json-number-decimal-comma.hpl
similarity index 56%
copy from integration-tests/json/0009-json-normalize-root-array.hpl
copy to integration-tests/json/0020-json-number-decimal-comma.hpl
index ab497e9a57..6e2807d1c9 100644
--- a/integration-tests/json/0009-json-normalize-root-array.hpl
+++ b/integration-tests/json/0020-json-number-decimal-comma.hpl
@@ -26,34 +26,18 @@ limitations under the License.
     <pipeline_type>Normal</pipeline_type>
     <pipeline_status>0</pipeline_status>
     <parameters/>
-    <name>0009-json-normalize-root-array</name>
+    <name>0020-json-number-decimal-comma</name>
     <name_sync_with_filename>Y</name_sync_with_filename>
-    <description/>
+    <description>A JSON number is read as the number it is: the decimal and 
grouping symbols of the field are for text. With a comma as decimal symbol, 
199.5 used to come out as 1995.</description>
     <extended_description/>
     <created_user>-</created_user>
+    <created_date>2026/11/13 12:00:00.000</created_date>
     <modified_user>-</modified_user>
-    <created_date>2026/05/08 14:00:00.000</created_date>
-    <modified_date>2026/05/08 14:00:00.000</modified_date>
+    <modified_date>2026/11/13 12:00:00.000</modified_date>
   </info>
-  <transform>
-    <type>Dummy</type>
-    <name>Validate</name>
-    <distribute>Y</distribute>
-    <copies>1</copies>
-    <GUI>
-      <xloc>352</xloc>
-      <yloc>192</yloc>
-    </GUI>
-    <description/>
-    <partitioning>
-      <method>none</method>
-      <schema_name/>
-    </partitioning>
-    <attributes/>
-  </transform>
   <transform>
     <type>JsonNormalizeInput</type>
-    <name>JSON normalize events</name>
+    <name>JSON normalize amounts</name>
     <include>N</include>
     <include_field/>
     <rownum>N</rownum>
@@ -64,15 +48,15 @@ limitations under the License.
     <IsAFile>N</IsAFile>
     <addresultfile>N</addresultfile>
     <IsIgnoreEmptyFile>N</IsIgnoreEmptyFile>
-    <doNotFailIfNoFile>Y</doNotFailIfNoFile>
+    <doNotFailIfNoFile>N</doNotFailIfNoFile>
     <readurl>N</readurl>
     <removeSourceField>N</removeSourceField>
-    <recordPath>$.events[*]</recordPath>
+    <recordPath>$.amounts[*]</recordPath>
     <fieldSeparator>.</fieldSeparator>
     <maxFlattenDepth>-1</maxFlattenDepth>
     <arrayHandling>STRINGIFY</arrayHandling>
     <beyondDepthBehavior>STRINGIFY</beyondDepthBehavior>
-    <ignoreMissingField>Y</ignoreMissingField>
+    <ignoreMissingField>N</ignoreMissingField>
     <shortFileFieldName/>
     <extensionFieldName/>
     <pathFieldName/>
@@ -83,7 +67,7 @@ limitations under the License.
     <rootUriNameFieldName/>
     <files>
       <file>
-        
<name>${HOP_UNIT_TESTS_FOLDER}/resources/json-normalize-events-it.json</name>
+        
<name>${HOP_UNIT_TESTS_FOLDER}/resources/json-number-decimal-comma-it.json</name>
         <filemask/>
         <exclude_filemask/>
         <file_required>N</file_required>
@@ -105,20 +89,56 @@ limitations under the License.
         <path>id</path>
       </field>
       <field>
-        <name>event</name>
+        <name>amount</name>
         <length>-1</length>
-        <type>String</type>
+        <type>Number</type>
         <format/>
         <trim_type>none</trim_type>
         <precision>-1</precision>
         <currency/>
-        <decimal/>
-        <group/>
+        <decimal>,</decimal>
+        <group>.</group>
         <repeat>N</repeat>
-        <path>event</path>
+        <path>amount</path>
       </field>
+    </fields>
+    <distribute>Y</distribute>
+    <copies>1</copies>
+    <GUI>
+      <xloc>128</xloc>
+      <yloc>96</yloc>
+    </GUI>
+    <description>A JSON number into a Number field whose decimal symbol is a 
comma.</description>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <attributes/>
+  </transform>
+  <transform>
+    <type>JsonInput</type>
+    <name>JSON input amounts</name>
+    <include>N</include>
+    <include_field/>
+    <rownum>N</rownum>
+    <addresultfile>N</addresultfile>
+    <readurl>N</readurl>
+    <removeSourceField>N</removeSourceField>
+    <IsIgnoreEmptyFile>N</IsIgnoreEmptyFile>
+    <doNotFailIfNoFile>N</doNotFailIfNoFile>
+    <ignoreMissingPath>N</ignoreMissingPath>
+    <defaultPathLeafToNull>Y</defaultPathLeafToNull>
+    <rownum_field/>
+    <file>
+      
<name>${HOP_UNIT_TESTS_FOLDER}/resources/json-number-decimal-comma-it.json</name>
+      <filemask/>
+      <exclude_filemask/>
+      <file_required>N</file_required>
+      <include_subfolders>N</include_subfolders>
+    </file>
+    <fields>
       <field>
-        <name>meta_ip</name>
+        <name>id</name>
         <length>-1</length>
         <type>String</type>
         <format/>
@@ -128,27 +148,71 @@ limitations under the License.
         <decimal/>
         <group/>
         <repeat>N</repeat>
-        <path>meta.ip</path>
+        <path>$.amounts[*].id</path>
       </field>
       <field>
-        <name>meta_amount</name>
+        <name>amount</name>
         <length>-1</length>
-        <type>Number</type>
+        <type>BigNumber</type>
         <format/>
         <trim_type>none</trim_type>
         <precision>-1</precision>
         <currency/>
-        <decimal/>
-        <group/>
+        <decimal>,</decimal>
+        <group>.</group>
         <repeat>N</repeat>
-        <path>meta.amount</path>
+        <path>$.amounts[*].amount</path>
       </field>
     </fields>
+    <limit>0</limit>
+    <IsInFields>N</IsInFields>
+    <IsAFile>N</IsAFile>
+    <valueField/>
+    <shortFileFieldName/>
+    <pathFieldName/>
+    <hiddenFieldName/>
+    <lastModificationTimeFieldName/>
+    <uriNameFieldName/>
+    <rootUriNameFieldName/>
+    <extensionFieldName/>
+    <sizeFieldName/>
     <distribute>Y</distribute>
     <copies>1</copies>
     <GUI>
       <xloc>128</xloc>
-      <yloc>192</yloc>
+      <yloc>224</yloc>
+    </GUI>
+    <description>A JSON number into a BigNumber field whose decimal symbol is 
a comma.</description>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <attributes/>
+  </transform>
+  <transform>
+    <type>Dummy</type>
+    <name>Validate normalize</name>
+    <distribute>Y</distribute>
+    <copies>1</copies>
+    <GUI>
+      <xloc>384</xloc>
+      <yloc>96</yloc>
+    </GUI>
+    <description/>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <attributes/>
+  </transform>
+  <transform>
+    <type>Dummy</type>
+    <name>Validate input</name>
+    <distribute>Y</distribute>
+    <copies>1</copies>
+    <GUI>
+      <xloc>384</xloc>
+      <yloc>224</yloc>
     </GUI>
     <description/>
     <partitioning>
@@ -159,8 +223,13 @@ limitations under the License.
   </transform>
   <order>
     <hop>
-      <from>JSON normalize events</from>
-      <to>Validate</to>
+      <from>JSON normalize amounts</from>
+      <to>Validate normalize</to>
+      <enabled>Y</enabled>
+    </hop>
+    <hop>
+      <from>JSON input amounts</from>
+      <to>Validate input</to>
       <enabled>Y</enabled>
     </hop>
   </order>
diff --git 
a/integration-tests/json/datasets/golden-json-number-decimal-comma-input.csv 
b/integration-tests/json/datasets/golden-json-number-decimal-comma-input.csv
new file mode 100644
index 0000000000..2e6a6a3326
--- /dev/null
+++ b/integration-tests/json/datasets/golden-json-number-decimal-comma-input.csv
@@ -0,0 +1,5 @@
+id,amount
+1,199.5
+2,1234.75
+3,-12.25
+4,7
diff --git 
a/integration-tests/json/datasets/golden-json-number-decimal-comma-normalize.csv
 
b/integration-tests/json/datasets/golden-json-number-decimal-comma-normalize.csv
new file mode 100644
index 0000000000..2e6a6a3326
--- /dev/null
+++ 
b/integration-tests/json/datasets/golden-json-number-decimal-comma-normalize.csv
@@ -0,0 +1,5 @@
+id,amount
+1,199.5
+2,1234.75
+3,-12.25
+4,7
diff --git a/integration-tests/json/main-0020-json-number-decimal-comma.hwf 
b/integration-tests/json/main-0020-json-number-decimal-comma.hwf
new file mode 100644
index 0000000000..059b8e583b
--- /dev/null
+++ b/integration-tests/json/main-0020-json-number-decimal-comma.hwf
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+  <name>main-0020-json-number-decimal-comma</name>
+  <name_sync_with_filename>Y</name_sync_with_filename>
+  <description/>
+  <extended_description/>
+  <created_user>-</created_user>
+  <modified_user>-</modified_user>
+  <created_date>2026/11/13 12:00:00.000</created_date>
+  <modified_date>2026/11/13 12:00:00.000</modified_date>
+  <workflow_version/>
+  <parameters/>
+  <actions>
+    <action>
+      <repeat>N</repeat>
+      <schedulerType>0</schedulerType>
+      <intervalSeconds>0</intervalSeconds>
+      <intervalMinutes>60</intervalMinutes>
+      <DayOfMonth>1</DayOfMonth>
+      <weekDay>1</weekDay>
+      <minutes>0</minutes>
+      <hour>12</hour>
+      <doNotWaitOnFirstExecution>N</doNotWaitOnFirstExecution>
+      <name>Start</name>
+      <description/>
+      <type>SPECIAL</type>
+      <attributes/>
+      <xloc>50</xloc>
+      <yloc>50</yloc>
+      <parallel>N</parallel>
+      <attributes_hac/>
+    </action>
+    <action>
+      <test_names>
+        <test_name>
+          <name>0020-json-number-decimal-comma UNIT</name>
+        </test_name>
+      </test_names>
+      <name>Run Pipeline Unit Tests</name>
+      <description/>
+      <type>RunPipelineTests</type>
+      <attributes/>
+      <xloc>256</xloc>
+      <yloc>48</yloc>
+      <parallel>N</parallel>
+      <attributes_hac/>
+    </action>
+  </actions>
+  <hops>
+    <hop>
+      <from>Start</from>
+      <to>Run Pipeline Unit Tests</to>
+      <evaluation>Y</evaluation>
+      <unconditional>Y</unconditional>
+      <enabled>Y</enabled>
+    </hop>
+  </hops>
+  <notepads/>
+  <attributes/>
+</workflow>
diff --git 
a/integration-tests/json/metadata/dataset/golden-json-number-decimal-comma-input.json
 
b/integration-tests/json/metadata/dataset/golden-json-number-decimal-comma-input.json
new file mode 100644
index 0000000000..e9bcb603a1
--- /dev/null
+++ 
b/integration-tests/json/metadata/dataset/golden-json-number-decimal-comma-input.json
@@ -0,0 +1,25 @@
+{
+  "base_filename": "golden-json-number-decimal-comma-input.csv",
+  "virtualPath": "",
+  "name": "golden-json-number-decimal-comma-input",
+  "description": "",
+  "dataset_fields": [
+    {
+      "field_comment": "",
+      "field_length": -1,
+      "field_type": 2,
+      "field_precision": -1,
+      "field_name": "id",
+      "field_format": ""
+    },
+    {
+      "field_comment": "",
+      "field_length": -1,
+      "field_type": 6,
+      "field_precision": -1,
+      "field_name": "amount",
+      "field_format": ""
+    }
+  ],
+  "folder_name": "${HOP_DATASETS_FOLDER}"
+}
diff --git 
a/integration-tests/json/metadata/dataset/golden-json-number-decimal-comma-normalize.json
 
b/integration-tests/json/metadata/dataset/golden-json-number-decimal-comma-normalize.json
new file mode 100644
index 0000000000..029ad4c10e
--- /dev/null
+++ 
b/integration-tests/json/metadata/dataset/golden-json-number-decimal-comma-normalize.json
@@ -0,0 +1,25 @@
+{
+  "base_filename": "golden-json-number-decimal-comma-normalize.csv",
+  "virtualPath": "",
+  "name": "golden-json-number-decimal-comma-normalize",
+  "description": "",
+  "dataset_fields": [
+    {
+      "field_comment": "",
+      "field_length": -1,
+      "field_type": 2,
+      "field_precision": -1,
+      "field_name": "id",
+      "field_format": ""
+    },
+    {
+      "field_comment": "",
+      "field_length": -1,
+      "field_type": 1,
+      "field_precision": -1,
+      "field_name": "amount",
+      "field_format": ""
+    }
+  ],
+  "folder_name": "${HOP_DATASETS_FOLDER}"
+}
diff --git 
a/integration-tests/json/metadata/unit-test/0020-json-number-decimal-comma 
UNIT.json 
b/integration-tests/json/metadata/unit-test/0020-json-number-decimal-comma 
UNIT.json
new file mode 100644
index 0000000000..606952fe77
--- /dev/null
+++ b/integration-tests/json/metadata/unit-test/0020-json-number-decimal-comma 
UNIT.json        
@@ -0,0 +1,49 @@
+{
+  "database_replacements": [],
+  "autoOpening": true,
+  "description": "",
+  "persist_filename": "",
+  "test_type": "UNIT_TEST",
+  "variableValues": [],
+  "basePath": "${HOP_UNIT_TESTS_FOLDER}",
+  "golden_data_sets": [
+    {
+      "field_mappings": [
+        {
+          "transform_field": "id",
+          "data_set_field": "id"
+        },
+        {
+          "transform_field": "amount",
+          "data_set_field": "amount"
+        }
+      ],
+      "field_order": [
+        "id"
+      ],
+      "data_set_name": "golden-json-number-decimal-comma-normalize",
+      "transform_name": "Validate normalize"
+    },
+    {
+      "field_mappings": [
+        {
+          "transform_field": "id",
+          "data_set_field": "id"
+        },
+        {
+          "transform_field": "amount",
+          "data_set_field": "amount"
+        }
+      ],
+      "field_order": [
+        "id"
+      ],
+      "data_set_name": "golden-json-number-decimal-comma-input",
+      "transform_name": "Validate input"
+    }
+  ],
+  "input_data_sets": [],
+  "name": "0020-json-number-decimal-comma UNIT",
+  "trans_test_tweaks": [],
+  "pipeline_filename": "./0020-json-number-decimal-comma.hpl"
+}
diff --git a/integration-tests/json/resources/json-number-decimal-comma-it.json 
b/integration-tests/json/resources/json-number-decimal-comma-it.json
new file mode 100644
index 0000000000..b047041087
--- /dev/null
+++ b/integration-tests/json/resources/json-number-decimal-comma-it.json
@@ -0,0 +1,20 @@
+{
+  "amounts": [
+    {
+      "id": 1,
+      "amount": 199.5
+    },
+    {
+      "id": 2,
+      "amount": 1234.75
+    },
+    {
+      "id": 3,
+      "amount": -12.25
+    },
+    {
+      "id": 4,
+      "amount": 7
+    }
+  ]
+}
diff --git 
a/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsoninput/reader/RowOutputConverter.java
 
b/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsoninput/reader/RowOutputConverter.java
index 4869feef34..792495a94a 100644
--- 
a/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsoninput/reader/RowOutputConverter.java
+++ 
b/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsoninput/reader/RowOutputConverter.java
@@ -19,6 +19,8 @@ package org.apache.hop.pipeline.transforms.jsoninput.reader;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.node.TextNode;
+import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.util.Map;
 import net.minidev.json.JSONObject;
 import org.apache.hop.core.exception.HopException;
@@ -40,6 +42,10 @@ public class RowOutputConverter {
   private Object getValue(IValueMeta targetMeta, IValueMeta strConvertMeta, 
Object value)
       throws HopValueException {
     if (targetMeta.isNumeric()) {
+      Object number = directNumber(targetMeta, value);
+      if (number != null) {
+        return number;
+      }
       try {
         // attempt direct conversion
         return targetMeta.getNativeDataType(value);
@@ -60,6 +66,93 @@ public class RowOutputConverter {
         strValue, strConvertMeta, null, null, targetMeta.getTrimType());
   }
 
+  /**
+   * A JSON number as the value of a numeric field.
+   *
+   * <p>A number in JSON is a number, written the one way JSON allows: digits, 
a dot, an exponent.
+   * It is not text in the format of the field, so the field's mask, decimal 
and grouping symbols
+   * are not used to read it: those say how the field is shown and how a JSON 
<em>string</em> is
+   * parsed. Reading the number through them would give 1995 for 199.5 
wherever the comma is the
+   * decimal symbol.
+   *
+   * <p>The value is what parsing its text with a dot as decimal symbol gives: 
a decimal put into an
+   * Integer field loses its fraction.
+   *
+   * @return the value, or null when the value is not a JSON number or has to 
take the usual route
+   */
+  private static Object directNumber(IValueMeta targetMeta, Object value) {
+    int type = targetMeta.getType();
+    if (type != IValueMeta.TYPE_INTEGER
+        && type != IValueMeta.TYPE_NUMBER
+        && type != IValueMeta.TYPE_BIGNUMBER) {
+      return null;
+    }
+
+    // Whole numbers that fit a long
+    Long whole = null;
+    if (value instanceof JsonNode node) {
+      if (node.isIntegralNumber() && node.canConvertToLong()) {
+        whole = node.longValue();
+      }
+    } else if (value instanceof Integer
+        || value instanceof Long
+        || value instanceof Short
+        || value instanceof Byte) {
+      whole = ((Number) value).longValue();
+    }
+    if (whole != null) {
+      return switch (type) {
+        case IValueMeta.TYPE_INTEGER -> whole;
+        case IValueMeta.TYPE_NUMBER -> (double) whole;
+        default -> BigDecimal.valueOf(whole);
+      };
+    }
+
+    // A double into a Number field needs no detour
+    if (type == IValueMeta.TYPE_NUMBER) {
+      if (value instanceof Double number) {
+        return Double.isNaN(number) || Double.isInfinite(number) ? null : 
number;
+      }
+      if (value instanceof JsonNode node && node.isDouble()) {
+        return node.doubleValue();
+      }
+    }
+
+    // Every other number, by its exact decimal value
+    BigDecimal decimal;
+    if (value instanceof JsonNode node) {
+      if (!node.isNumber()) {
+        return null;
+      }
+      // a float or double node by its text: 0.1f is 0.1, not 
0.100000001490116...
+      decimal = node.isFloatingPointNumber() ? new BigDecimal(node.asText()) : 
node.decimalValue();
+    } else if (value instanceof Double || value instanceof Float) {
+      double number = ((Number) value).doubleValue();
+      if (Double.isNaN(number) || Double.isInfinite(number)) {
+        return null;
+      }
+      decimal = new BigDecimal(value.toString());
+    } else if (value instanceof BigDecimal bigDecimal) {
+      decimal = bigDecimal;
+    } else if (value instanceof BigInteger bigInteger) {
+      decimal = new BigDecimal(bigInteger);
+    } else {
+      return null;
+    }
+    switch (type) {
+      case IValueMeta.TYPE_NUMBER:
+        return decimal.doubleValue();
+      case IValueMeta.TYPE_BIGNUMBER:
+        return decimal;
+      default:
+        // An Integer field: drop the fraction. A value outside the range of a 
long takes the
+        // usual route, which decides what happens to it.
+        return decimal.abs().compareTo(LONG_RANGE) < 0 ? (Object) 
decimal.longValue() : null;
+    }
+  }
+
+  private static final BigDecimal LONG_RANGE = 
BigDecimal.valueOf(Long.MAX_VALUE);
+
   // Package-private and static so RowOutputConverterTest can exercise it 
directly
   // without instantiating the surrounding transform.
   static String getStringValue(Object jo) {
diff --git 
a/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsonnormalize/JsonNormalizeInput.java
 
b/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsonnormalize/JsonNormalizeInput.java
index db2cb6f511..8a6e0e9637 100644
--- 
a/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsonnormalize/JsonNormalizeInput.java
+++ 
b/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsonnormalize/JsonNormalizeInput.java
@@ -154,7 +154,11 @@ public class JsonNormalizeInput
     data.inputRowMeta = getInputRowMeta();
     if (!meta.isInFields() && data.inputRowMeta == null) {
       data.outputRowMeta = new RowMeta();
-      if (!meta.isDoNotFailIfNoFile() && (data.files == null || 
data.files.nrOfFiles() == 0)) {
+      if (data.files == null) {
+        // The check below is about the files: have the list before asking how 
many there are
+        data.files = meta.getFileInputList(this);
+      }
+      if (!meta.isDoNotFailIfNoFile() && data.files.nrOfFiles() == 0) {
         String errMsg = BaseMessages.getString(JsonInputMeta.class, 
"JsonInput.Log.NoFiles");
         logError(errMsg);
         inputError(errMsg);
diff --git 
a/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonOutput.java
 
b/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonOutput.java
index 6ff2efcf5b..b48ce3fe09 100644
--- 
a/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonOutput.java
+++ 
b/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonOutput.java
@@ -43,8 +43,6 @@ import org.apache.hop.pipeline.Pipeline;
 import org.apache.hop.pipeline.PipelineMeta;
 import org.apache.hop.pipeline.transform.BaseTransform;
 import org.apache.hop.pipeline.transform.TransformMeta;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
 
 /** Converts input rows to one or more Xml files. */
 public class JsonOutput extends BaseTransform<JsonOutputMeta, JsonOutputData> {
@@ -64,41 +62,46 @@ public class JsonOutput extends 
BaseTransform<JsonOutputMeta, JsonOutputData> {
 
   public void execute(Object[] row) throws HopException {
 
-    // Create a new object with specified fields
-    JSONObject jo = new JSONObject();
-
+    // The values of the row, in the order of the output fields
+    Object[] values = new Object[data.nrFields];
     for (int i = 0; i < data.nrFields; i++) {
-      JsonOutputField outputField = meta.getOutputFields().get(i);
-
-      IValueMeta v = data.inputRowMeta.getValueMeta(data.fieldIndexes[i]);
+      int index = data.fieldIndexes[i];
+      IValueMeta v = data.inputRowMeta.getValueMeta(index);
 
       switch (v.getType()) {
         case IValueMeta.TYPE_BOOLEAN:
-          jo.put(
-              outputField.getElementName(),
-              data.inputRowMeta.getBoolean(row, data.fieldIndexes[i]));
+          values[i] = data.inputRowMeta.getBoolean(row, index);
           break;
         case IValueMeta.TYPE_INTEGER:
-          jo.put(
-              outputField.getElementName(),
-              data.inputRowMeta.getInteger(row, data.fieldIndexes[i]));
+          values[i] = data.inputRowMeta.getInteger(row, index);
           break;
         case IValueMeta.TYPE_NUMBER:
-          jo.put(
-              outputField.getElementName(), data.inputRowMeta.getNumber(row, 
data.fieldIndexes[i]));
+          values[i] = data.inputRowMeta.getNumber(row, index);
           break;
         case IValueMeta.TYPE_BIGNUMBER:
-          jo.put(
-              outputField.getElementName(),
-              data.inputRowMeta.getBigNumber(row, data.fieldIndexes[i]));
+          values[i] = data.inputRowMeta.getBigNumber(row, index);
           break;
         default:
-          jo.put(
-              outputField.getElementName(), data.inputRowMeta.getString(row, 
data.fieldIndexes[i]));
+          values[i] = data.inputRowMeta.getString(row, index);
           break;
       }
     }
-    data.ja.add(jo);
+
+    // Add the row to the text of the block. A block that only goes to a file 
is written as the
+    // rows come in, so it never has to fit in memory as a whole.
+    boolean first = data.blockRows == 0;
+    if (first) {
+      startBlock();
+      if (data.streamsToFile() && !openNewFile()) {
+        throw new HopTransformException(
+            BaseMessages.getString(PKG, "JsonOutput.Error.OpenNewFile", 
buildFilename()));
+      }
+    }
+    data.rowsText.appendRow(data.block, first, values);
+    data.blockRows++;
+    if (data.streamsToFile()) {
+      writeBlockText();
+    }
 
     data.nrRow++;
 
@@ -108,6 +111,24 @@ public class JsonOutput extends 
BaseTransform<JsonOutputMeta, JsonOutputData> {
     }
   }
 
+  private void startBlock() {
+    if (data.block == null) {
+      data.block = new StringBuilder();
+    }
+    data.block.setLength(0);
+    JsonRowsText.appendStart(data.block, data.realBlocName);
+  }
+
+  /** Writes the text collected so far to the open file. */
+  private void writeBlockText() throws HopTransformException {
+    try {
+      data.writer.write(data.block.toString());
+      data.block.setLength(0);
+    } catch (Exception e) {
+      throw new HopTransformException(BaseMessages.getString(PKG, 
"JsonOutput.Error.Writing"), e);
+    }
+  }
+
   @Override
   public boolean processRow() throws HopException {
     Object[] r = getRow(); // This also waits for a row to be finished.
@@ -131,6 +152,7 @@ public class JsonOutput extends 
BaseTransform<JsonOutputMeta, JsonOutputData> {
       //
       data.nrFields = meta.getOutputFields().size();
       data.fieldIndexes = new int[data.nrFields];
+      List<String> elementNames = new ArrayList<>();
       for (int i = 0; i < data.nrFields; i++) {
         data.fieldIndexes[i] =
             
data.inputRowMeta.indexOfValue(meta.getOutputFields().get(i).getFieldName());
@@ -139,7 +161,9 @@ public class JsonOutput extends 
BaseTransform<JsonOutputMeta, JsonOutputData> {
         }
         JsonOutputField field = meta.getOutputFields().get(i);
         field.setElementName(resolve(field.getElementName()));
+        elementNames.add(field.getElementName());
       }
+      data.rowsText = new JsonRowsText(elementNames);
     }
 
     data.rowsAreSafe = false;
@@ -163,35 +187,35 @@ public class JsonOutput extends 
BaseTransform<JsonOutputMeta, JsonOutputData> {
 
   private void outputRow(Object[] rowData) throws HopTransformException {
     // We can now output an object
-    data.jg = new JSONObject();
-    data.jg.put(data.realBlocName, data.ja);
-    String value = data.jg.toJSONString();
+    boolean hasRows = data.blockRows > 0;
+    if (!hasRows) {
+      startBlock();
+    }
+    JsonRowsText.appendEnd(data.block);
 
     if (data.outputValue && data.outputRowMeta != null) {
-      Object[] outputRowData = RowDataUtil.addValueData(rowData, 
data.inputRowMetaSize, value);
+      Object[] outputRowData =
+          RowDataUtil.addValueData(rowData, data.inputRowMetaSize, 
data.block.toString());
       incrementLinesOutput();
       putRow(data.outputRowMeta, outputRowData);
     }
 
-    if (data.writeToFile && !data.ja.isEmpty()) {
+    if (data.writeToFile && hasRows) {
       // Open a file
       if (!openNewFile()) {
         throw new HopTransformException(
             BaseMessages.getString(PKG, "JsonOutput.Error.OpenNewFile", 
buildFilename()));
       }
-      // Write data to file
-      try {
-        data.writer.write(value);
-      } catch (Exception e) {
-        throw new HopTransformException(BaseMessages.getString(PKG, 
"JsonOutput.Error.Writing"), e);
-      }
+      // Write data to file: the whole block, or what is left of it when the 
rows went out already
+      writeBlockText();
       // Close file
       closeFile();
     }
     // Data are safe
     data.rowsAreSafe = true;
     data.lastRow = null;
-    data.ja = new JSONArray();
+    data.block.setLength(0);
+    data.blockRows = 0;
   }
 
   @Override
@@ -236,20 +260,14 @@ public class JsonOutput extends 
BaseTransform<JsonOutputMeta, JsonOutputData> {
 
   @Override
   public void dispose() {
-    if (data.ja != null) {
-      // Is there some left-over data to be written to disk?
-      //
-      if (!data.ja.isEmpty()) {
-        try {
-          outputRow(data.lastRow);
-        } catch (Exception e) {
-          logError("Error writing final rows to disk", e);
-        }
+    // Is there some left-over data to be written to disk?
+    //
+    if (data.blockRows > 0) {
+      try {
+        outputRow(data.lastRow);
+      } catch (Exception e) {
+        logError("Error writing final rows to disk", e);
       }
-      data.ja = null;
-    }
-    if (data.jg != null) {
-      data.jg = null;
     }
     closeFile();
     super.dispose();
diff --git 
a/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonOutputData.java
 
b/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonOutputData.java
index 92221b4e6e..c6a79dd0ff 100644
--- 
a/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonOutputData.java
+++ 
b/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonOutputData.java
@@ -27,8 +27,6 @@ import org.apache.hop.core.io.CountingOutputStream;
 import org.apache.hop.core.row.IRowMeta;
 import org.apache.hop.pipeline.transform.BaseTransformData;
 import org.apache.hop.pipeline.transform.ITransformData;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
 
 @SuppressWarnings("java:S1104")
 public class JsonOutputData extends BaseTransformData implements 
ITransformData {
@@ -39,8 +37,19 @@ public class JsonOutputData extends BaseTransformData 
implements ITransformData
   public int nrFields;
 
   public int[] fieldIndexes;
-  public JSONObject jg;
-  public JSONArray ja;
+
+  /** Writes the rows as JSON text, see {@link JsonRowsText}. Set on the first 
row. */
+  JsonRowsText rowsText;
+
+  /**
+   * The text of the block of rows that is being collected. When the block 
only goes to a file it
+   * holds the part that is not written yet.
+   */
+  public StringBuilder block = new StringBuilder();
+
+  /** The number of rows in the block so far. */
+  public int blockRows;
+
   public int nrRow;
   public boolean rowsAreSafe;
   public NumberFormat nf;
@@ -78,11 +87,19 @@ public class JsonOutputData extends BaseTransformData 
implements ITransformData
   /** */
   public JsonOutputData() {
     super();
-    this.ja = new JSONArray();
     this.nrRow = 0;
     this.outputValue = false;
     this.writeToFile = false;
     this.writer = null;
     this.nrRowsInBloc = 0;
   }
+
+  /**
+   * @return true when the JSON only goes to a file: the rows are then written 
as they come in. When
+   *     the JSON also goes to an output field, the text of the whole block is 
needed for that
+   *     field.
+   */
+  public boolean streamsToFile() {
+    return writeToFile && !outputValue;
+  }
 }
diff --git 
a/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonRowsText.java
 
b/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonRowsText.java
new file mode 100644
index 0000000000..9b20f08b06
--- /dev/null
+++ 
b/plugins/transforms/json/src/main/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonRowsText.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.jsonoutput;
+
+import java.util.List;
+import java.util.Map;
+import org.json.simple.JSONObject;
+import org.json.simple.JSONValue;
+
+/**
+ * Writes the JSON of the JSON output transform one row at a time, with 
exactly the text json-simple
+ * gives for a {@code JSONObject} that holds a {@code JSONArray} of one {@code 
JSONObject} per row.
+ *
+ * <p>Building those objects for every row keeps the whole document in memory 
until it is written.
+ * Here only the text is produced. To keep that text the same, two habits of 
json-simple are
+ * reproduced: it keeps an object in a hash map, so the element names come out 
in that map's order
+ * and not in the order of the fields, and a name that is used twice keeps the 
value that was put
+ * last. Values and names are written by json-simple itself, so escaping does 
not change.
+ */
+final class JsonRowsText {
+
+  private static final String END = "]}";
+
+  /** The element names, quoted and escaped and followed by a colon, in the 
order to write them. */
+  private final String[] keys;
+
+  /** For each key: the position of its value in the row's values. */
+  private final int[] valueIndexes;
+
+  /**
+   * @param elementNames the element name of each value of a row, in the order 
of the values
+   */
+  JsonRowsText(List<String> elementNames) {
+    // What json-simple does with these names: its map decides the order, the 
last one wins.
+    JSONObject order = new JSONObject();
+    for (int i = 0; i < elementNames.size(); i++) {
+      order.put(elementNames.get(i), i);
+    }
+    keys = new String[order.size()];
+    valueIndexes = new int[order.size()];
+    int k = 0;
+    for (Object object : order.entrySet()) {
+      Map.Entry<?, ?> entry = (Map.Entry<?, ?>) object;
+      Object name = entry.getKey();
+      // json-simple writes String.valueOf(key), also for a null name
+      keys[k] = '"' + JSONValue.escape(String.valueOf(name)) + "\":";
+      valueIndexes[k] = (Integer) entry.getValue();
+      k++;
+    }
+  }
+
+  /** Starts a document: an object with one element, the array of rows. */
+  static void appendStart(StringBuilder text, String blockName) {
+    
text.append("{\"").append(JSONValue.escape(String.valueOf(blockName))).append("\":[");
+  }
+
+  /** Ends the document that {@link #appendStart} started. */
+  static void appendEnd(StringBuilder text) {
+    text.append(END);
+  }
+
+  /**
+   * Adds one row to the array.
+   *
+   * @param first true for the first row of the document
+   * @param values the values of the row, one for each element name given to 
the constructor
+   */
+  void appendRow(StringBuilder text, boolean first, Object[] values) {
+    if (!first) {
+      text.append(',');
+    }
+    text.append('{');
+    for (int k = 0; k < keys.length; k++) {
+      if (k > 0) {
+        text.append(',');
+      }
+      
text.append(keys[k]).append(JSONValue.toJSONString(values[valueIndexes[k]]));
+    }
+    text.append('}');
+  }
+}
diff --git 
a/plugins/transforms/json/src/test/java/org/apache/hop/pipeline/transforms/jsoninput/reader/RowOutputConverterNumberTest.java
 
b/plugins/transforms/json/src/test/java/org/apache/hop/pipeline/transforms/jsoninput/reader/RowOutputConverterNumberTest.java
new file mode 100644
index 0000000000..2753edfe80
--- /dev/null
+++ 
b/plugins/transforms/json/src/test/java/org/apache/hop/pipeline/transforms/jsoninput/reader/RowOutputConverterNumberTest.java
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.jsoninput.reader;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.fasterxml.jackson.databind.node.BigIntegerNode;
+import com.fasterxml.jackson.databind.node.DecimalNode;
+import com.fasterxml.jackson.databind.node.DoubleNode;
+import com.fasterxml.jackson.databind.node.FloatNode;
+import com.fasterxml.jackson.databind.node.IntNode;
+import com.fasterxml.jackson.databind.node.LongNode;
+import com.fasterxml.jackson.databind.node.TextNode;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.BitSet;
+import java.util.List;
+import org.apache.hop.core.HopEnvironment;
+import org.apache.hop.core.exception.HopException;
+import org.apache.hop.core.logging.ILogChannel;
+import org.apache.hop.core.plugins.PluginRegistry;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.RowMeta;
+import org.apache.hop.core.row.value.ValueMetaBigNumber;
+import org.apache.hop.core.row.value.ValueMetaFactory;
+import org.apache.hop.core.row.value.ValueMetaInteger;
+import org.apache.hop.core.row.value.ValueMetaNumber;
+import org.apache.hop.core.row.value.ValueMetaPlugin;
+import org.apache.hop.core.row.value.ValueMetaPluginType;
+import org.apache.hop.core.row.value.ValueMetaString;
+import org.apache.hop.pipeline.transforms.jsoninput.JsonInputData;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+/**
+ * A JSON number is a number: it goes into a numeric field as the value it is, 
whatever the format
+ * and the symbols of the field are. Those are for showing the field and for 
parsing a JSON string.
+ * The value has to be what parsing the number's text with a dot as decimal 
symbol gives, and the
+ * debug message of the failed cast tells whether a value took the old route.
+ */
+class RowOutputConverterNumberTest {
+
+  @BeforeAll
+  static void initHop() throws HopException {
+    HopEnvironment.init();
+    // A test that ran before in this JVM may have registered only some value 
types, and init()
+    // does not add the others then: register every type this test uses.
+    PluginRegistry registry = PluginRegistry.getInstance();
+    for (Class<?> valueMeta :
+        List.of(
+            ValueMetaString.class,
+            ValueMetaInteger.class,
+            ValueMetaNumber.class,
+            ValueMetaBigNumber.class)) {
+      registry.registerPluginClass(
+          valueMeta.getName(), ValueMetaPluginType.class, 
ValueMetaPlugin.class);
+    }
+  }
+
+  private static IValueMeta field(int type, String mask, String decimalSymbol) 
throws HopException {
+    IValueMeta meta = ValueMetaFactory.createValueMeta("field", type);
+    meta.setConversionMask(mask);
+    meta.setDecimalSymbol(decimalSymbol);
+    meta.setGroupingSymbol(".".equals(decimalSymbol) ? "," : ".");
+    return meta;
+  }
+
+  /** Every way a numeric field of a type can be set up: none of it may change 
the value. */
+  private static List<IValueMeta> fields(int type) throws HopException {
+    return List.of(
+        field(type, null, "."),
+        field(type, null, ","),
+        field(type, "#,##0.00", "."),
+        field(type, "#,##0.00", ","),
+        field(type, "0.00E0", "."),
+        field(type, "#%", "."),
+        ValueMetaFactory.createValueMeta("field", type));
+  }
+
+  /** What parsing the text of the number gives in a field that reads a dot as 
decimal symbol. */
+  private static Object fromTextWithADot(int type, Object jsonValue) throws 
HopException {
+    IValueMeta plain = field(type, null, ".");
+    return plain.convertDataFromString(
+        RowOutputConverter.getStringValue(jsonValue),
+        ValueMetaFactory.createParseMeta(plain),
+        null,
+        null,
+        plain.getTrimType());
+  }
+
+  private static Object convert(IValueMeta target, Object jsonValue, 
ILogChannel log)
+      throws HopException {
+    JsonInputData data = new JsonInputData();
+    data.outputRowMeta = new RowMeta();
+    data.outputRowMeta.addValueMeta(target);
+    data.convertRowMeta = 
ValueMetaFactory.createParseRowMeta(data.outputRowMeta);
+    data.totalpreviousfields = 0;
+    data.repeatedFields = new BitSet(1);
+    return new RowOutputConverter(log).getRow(new Object[1], new Object[] 
{jsonValue}, data)[0];
+  }
+
+  private static ILogChannel debugLog() {
+    ILogChannel log = mock(ILogChannel.class);
+    when(log.isDebug()).thenReturn(true);
+    return log;
+  }
+
+  /** The value goes in directly, for every set-up of the field, and is the 
dot-decimal value. */
+  private static void assertTakenAsTheNumberItIs(int type, Object jsonValue) 
throws HopException {
+    Object expected = fromTextWithADot(type, jsonValue);
+    for (IValueMeta target : fields(type)) {
+      ILogChannel log = debugLog();
+      Object actual = convert(target, jsonValue, log);
+      String what =
+          jsonValue.getClass().getSimpleName()
+              + " "
+              + jsonValue
+              + " into "
+              + target.getTypeDesc()
+              + " mask="
+              + target.getConversionMask()
+              + " decimal="
+              + target.getDecimalSymbol();
+      if (expected instanceof BigDecimal big) {
+        assertEquals(0, big.compareTo((BigDecimal) actual), what);
+      } else {
+        assertEquals(expected, actual, what);
+      }
+      // the failed cast leaves a debug message; a value that is taken 
directly leaves none
+      verify(log, never()).logDebug(anyString(), any(Throwable.class));
+    }
+  }
+
+  private static final int[] NUMERIC_TYPES = {
+    IValueMeta.TYPE_INTEGER, IValueMeta.TYPE_NUMBER, IValueMeta.TYPE_BIGNUMBER
+  };
+
+  @Test
+  void wholeNumbers() throws HopException {
+    Object[] values = {
+      12,
+      12L,
+      (short) 12,
+      -7,
+      0,
+      Long.MAX_VALUE,
+      IntNode.valueOf(12),
+      LongNode.valueOf(-7L),
+      BigIntegerNode.valueOf(BigInteger.valueOf(123456789012L))
+    };
+    for (int type : NUMERIC_TYPES) {
+      for (Object value : values) {
+        assertTakenAsTheNumberItIs(type, value);
+      }
+    }
+  }
+
+  @Test
+  void decimals() throws HopException {
+    double[] decimals = {199.5, 12.4, -12.5, 0.0, 0.1 + 0.2, 9999999.75, 
1.0E10, 1.0E-5, 42.0};
+    for (int type : NUMERIC_TYPES) {
+      for (double decimal : decimals) {
+        // the default reader hands over a Double, a JSON value in a field a 
DoubleNode
+        assertTakenAsTheNumberItIs(type, decimal);
+        assertTakenAsTheNumberItIs(type, DoubleNode.valueOf(decimal));
+      }
+      assertTakenAsTheNumberItIs(type, DecimalNode.valueOf(new 
BigDecimal("12345.6789")));
+      assertTakenAsTheNumberItIs(type, FloatNode.valueOf(0.1f));
+    }
+  }
+
+  @Test
+  void aDecimalIntoAnIntegerFieldLosesItsFraction() throws HopException {
+    assertEquals(12L, convert(field(IValueMeta.TYPE_INTEGER, null, ","), 
12.9d, debugLog()));
+    assertEquals(
+        -12L,
+        convert(field(IValueMeta.TYPE_INTEGER, null, ","), 
DoubleNode.valueOf(-12.9), debugLog()));
+  }
+
+  /** The case that gave 1995 for 199.5 on a machine with the comma as decimal 
symbol. */
+  @Test
+  void theDecimalSymbolOfTheFieldDoesNotChangeAJsonNumber() throws 
HopException {
+    IValueMeta comma = field(IValueMeta.TYPE_NUMBER, null, ",");
+
+    assertEquals(199.5d, convert(comma, DoubleNode.valueOf(199.5), 
debugLog()));
+    assertEquals(199.5d, convert(comma, 199.5d, debugLog()));
+    assertEquals(
+        0,
+        new BigDecimal("199.5")
+            .compareTo(
+                (BigDecimal)
+                    convert(
+                        field(IValueMeta.TYPE_BIGNUMBER, null, ","),
+                        DoubleNode.valueOf(199.5),
+                        debugLog())));
+  }
+
+  /** A JSON string is text: it is still read with the format and the symbols 
of the field. */
+  @Test
+  void aJsonStringIsStillParsedWithTheFormatOfTheField() throws HopException {
+    // the mask is always written with a dot and a comma; the symbols say what 
stands for them
+    IValueMeta comma = field(IValueMeta.TYPE_NUMBER, "#,##0.00", ",");
+    assertEquals(1199.5d, convert(comma, TextNode.valueOf("1.199,50"), 
debugLog()));
+    assertEquals(1199.5d, convert(comma, "1.199,50", debugLog()));
+
+    IValueMeta dot = field(IValueMeta.TYPE_NUMBER, "#,##0.00", ".");
+    assertEquals(1199.5d, convert(dot, TextNode.valueOf("1,199.50"), 
debugLog()));
+
+    // text the format cannot read is an error, as it was
+    assertThrows(
+        HopException.class,
+        () -> convert(field(IValueMeta.TYPE_INTEGER, "$#", "."), "twelve", 
debugLog()));
+  }
+
+  /** A whole number too large for a long takes the route it always took into 
an Integer field. */
+  @Test
+  void aWholeNumberBeyondALongIsLeftToTheOldRouteForAnIntegerField() throws 
HopException {
+    BigIntegerNode huge = BigIntegerNode.valueOf(new 
BigInteger("123456789012345678901234567890"));
+    IValueMeta target = field(IValueMeta.TYPE_INTEGER, null, ".");
+
+    assertEquals(
+        fromTextWithADot(IValueMeta.TYPE_INTEGER, huge), convert(target, huge, 
debugLog()));
+    // Number and BigNumber fields can hold it
+    assertTakenAsTheNumberItIs(IValueMeta.TYPE_NUMBER, huge);
+    assertTakenAsTheNumberItIs(IValueMeta.TYPE_BIGNUMBER, huge);
+  }
+}
diff --git 
a/plugins/transforms/json/src/test/java/org/apache/hop/pipeline/transforms/jsonnormalize/JsonNormalizeSamplePipelinesTest.java
 
b/plugins/transforms/json/src/test/java/org/apache/hop/pipeline/transforms/jsonnormalize/JsonNormalizeSamplePipelinesTest.java
index 33cd1480e5..905ade6dd3 100644
--- 
a/plugins/transforms/json/src/test/java/org/apache/hop/pipeline/transforms/jsonnormalize/JsonNormalizeSamplePipelinesTest.java
+++ 
b/plugins/transforms/json/src/test/java/org/apache/hop/pipeline/transforms/jsonnormalize/JsonNormalizeSamplePipelinesTest.java
@@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
+import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import org.apache.hop.core.HopEnvironment;
@@ -35,6 +36,7 @@ import org.apache.hop.pipeline.transform.TransformMeta;
 import org.apache.hop.pipeline.transforms.TransformRowsCollector;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 /** Ensures shipped sample pipelines load and reference JsonNormalizeInput. */
 class JsonNormalizeSamplePipelinesTest {
@@ -134,6 +136,50 @@ class JsonNormalizeSamplePipelinesTest {
     assertEquals(1, cProj.getRowsRead().size(), "project configuration branch 
should emit 1 row");
   }
 
+  /** Runs the root array sample on a project folder, with "Do not fail if no 
file" off. */
+  private static Pipeline runRootArraySampleFailingWithoutFiles(Path 
projectHome) throws Exception {
+    Path hpl =
+        
Paths.get("src/main/samples/transforms/json-normalize-root-array.hpl").toAbsolutePath();
+    Variables variables = new Variables();
+    variables.setVariable("PROJECT_HOME", projectHome.toString());
+    PipelineMeta meta = new PipelineMeta(hpl.toString(), new 
MemoryMetadataProvider(), variables);
+    JsonNormalizeInputMeta normalize =
+        (JsonNormalizeInputMeta) meta.findTransform("read normalized 
events").getTransform();
+    normalize.setDoNotFailIfNoFile(false);
+
+    Pipeline pipeline = new LocalPipelineEngine(meta, variables, null);
+    pipeline.prepareExecution();
+    pipeline.startThreads();
+    pipeline.waitUntilFinished();
+    return pipeline;
+  }
+
+  /**
+   * With "Do not fail if no file" off the transform used to read every row 
and then report that
+   * there are no files: it asked before the list of files was made.
+   */
+  @Test
+  void aFileThatIsThereIsNotReportedAsMissing(@TempDir Path projectHome) 
throws Exception {
+    Files.createDirectories(projectHome.resolve("data"));
+    Files.writeString(
+        projectHome.resolve("data/json-normalize-events.json"),
+        
"[{\"id\":1,\"event\":\"login\",\"meta\":{\"ip\":\"10.0.0.1\",\"amount\":2.5}},"
+            + 
"{\"id\":2,\"event\":\"logout\",\"meta\":{\"ip\":\"10.0.0.2\",\"amount\":3}}]");
+
+    Pipeline pipeline = runRootArraySampleFailingWithoutFiles(projectHome);
+
+    assertEquals(0, pipeline.getResult().getNrErrors(), "Pipeline errors: " + 
pipeline.getResult());
+    assertEquals(
+        2, pipeline.findComponent("read normalized events", 
0).getLinesWritten(), "rows written");
+  }
+
+  @Test
+  void aMissingFileIsStillAnError(@TempDir Path projectHome) throws Exception {
+    Pipeline pipeline = runRootArraySampleFailingWithoutFiles(projectHome);
+
+    assertTrue(pipeline.getResult().getNrErrors() > 0);
+  }
+
   private static TransformRowsCollector attachCollector(Pipeline pipeline, 
String transformName) {
     IEngineComponent component = pipeline.findComponent(transformName, 0);
     TransformRowsCollector collector = new TransformRowsCollector();
diff --git 
a/plugins/transforms/json/src/test/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonOutputTest.java
 
b/plugins/transforms/json/src/test/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonOutputTest.java
index 97daf6b4ca..f7d0cb5d00 100644
--- 
a/plugins/transforms/json/src/test/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonOutputTest.java
+++ 
b/plugins/transforms/json/src/test/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonOutputTest.java
@@ -71,7 +71,6 @@ import org.apache.hop.pipeline.transforms.dummy.DummyMeta;
 import org.apache.hop.pipeline.transforms.mock.TransformMockHelper;
 import org.apache.hop.pipeline.transforms.rowgenerator.GeneratorField;
 import org.apache.hop.pipeline.transforms.rowgenerator.RowGeneratorMeta;
-import org.json.simple.JSONObject;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.ValueSource;
@@ -380,9 +379,9 @@ class JsonOutputTest {
 
     JsonOutputData transformData = new JsonOutputData();
     transformData.writeToFile = true;
-    JSONObject jsonObject = new JSONObject();
-    jsonObject.put("key", "value");
-    transformData.ja.add(jsonObject);
+    // one row is waiting to be written
+    transformData.block.append("{\"data\":[{\"key\":\"value\"}");
+    transformData.blockRows = 1;
     transformData.writer = mock(Writer.class);
 
     JsonOutput transform =
diff --git 
a/plugins/transforms/json/src/test/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonRowsTextTest.java
 
b/plugins/transforms/json/src/test/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonRowsTextTest.java
new file mode 100644
index 0000000000..8ca5e64461
--- /dev/null
+++ 
b/plugins/transforms/json/src/test/java/org/apache/hop/pipeline/transforms/jsonoutput/JsonRowsTextTest.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.jsonoutput;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.math.BigDecimal;
+import java.util.List;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.junit.jupiter.api.Test;
+
+/**
+ * {@link JsonRowsText} has to give, character for character, the text 
json-simple gives for the
+ * objects the transform used to build.
+ */
+class JsonRowsTextTest {
+
+  // not as unicode escapes: the compiler would read those as line ends inside 
the string
+  private static final char LINE_SEPARATOR = (char) 0x2028;
+  private static final char PARAGRAPH_SEPARATOR = (char) 0x2029;
+
+  /** The text the transform used to produce: an object holding an array of 
one object per row. */
+  @SuppressWarnings("unchecked")
+  private static String withJsonSimple(String blockName, List<String> names, 
Object[]... rows) {
+    JSONArray array = new JSONArray();
+    for (Object[] row : rows) {
+      JSONObject object = new JSONObject();
+      for (int i = 0; i < names.size(); i++) {
+        object.put(names.get(i), row[i]);
+      }
+      array.add(object);
+    }
+    JSONObject document = new JSONObject();
+    document.put(blockName, array);
+    return document.toJSONString();
+  }
+
+  private static String withRowsText(String blockName, List<String> names, 
Object[]... rows) {
+    JsonRowsText rowsText = new JsonRowsText(names);
+    StringBuilder text = new StringBuilder();
+    JsonRowsText.appendStart(text, blockName);
+    boolean first = true;
+    for (Object[] row : rows) {
+      rowsText.appendRow(text, first, row);
+      first = false;
+    }
+    JsonRowsText.appendEnd(text);
+    return text.toString();
+  }
+
+  private static void assertSameText(String blockName, List<String> names, 
Object[]... rows) {
+    assertEquals(withJsonSimple(blockName, names, rows), 
withRowsText(blockName, names, rows));
+  }
+
+  @Test
+  void everyValueTypeAndNull() {
+    assertSameText(
+        "data",
+        List.of("id", "price", "total", "active", "comment"),
+        new Object[] {1L, 12.5d, new BigDecimal("12345.6789"), true, "plain"},
+        new Object[] {-7L, 0.0d, new BigDecimal("0.10"), false, ""},
+        new Object[] {null, null, null, null, null});
+  }
+
+  @Test
+  void numbersThatJavaWritesWithAnExponentOrNotAtAll() {
+    assertSameText(
+        "data",
+        List.of("number", "bignumber"),
+        new Object[] {1.0E10d, new BigDecimal("1E+3")},
+        new Object[] {1.0E-5d, new BigDecimal("1E-10")},
+        new Object[] {Double.NaN, new 
BigDecimal("123456789012345678901234567890.5")},
+        new Object[] {Double.POSITIVE_INFINITY, BigDecimal.ZERO},
+        new Object[] {Double.MIN_VALUE, BigDecimal.ONE});
+  }
+
+  @Test
+  void textThatNeedsEscaping() {
+    assertSameText(
+        "data",
+        List.of("text"),
+        new Object[] {"quote \" backslash \\ slash / tab \t newline \n return 
\r"},
+        new Object[] {"control \u0001 \u001f delete \u007f \u009f"},
+        new Object[] {
+          "accents é ü ñ, snowman ☃, separators "
+              + LINE_SEPARATOR
+              + PARAGRAPH_SEPARATOR
+              + ", emoji 😀"
+        },
+        new Object[] {"</script>"});
+  }
+
+  @Test
+  void namesComeOutInTheOrderJsonSimpleUses() {
+    // json-simple keeps an object in a hash map: not the order of the fields
+    assertSameText(
+        "data",
+        List.of(
+            "order_id",
+            "customer_id",
+            "product_id",
+            "order_date",
+            "status",
+            "quantity",
+            "unit_price",
+            "discount",
+            "country",
+            "channel",
+            "comment"),
+        new Object[] {1L, 2L, 3L, "2026-01-01", "NEW", 4L, 5.5d, 0.1d, "BE", 
"web", "x"},
+        new Object[] {6L, 7L, 8L, "2026-01-02", "DONE", 9L, 1.5d, 0.0d, "NL", 
"shop", null});
+  }
+
+  @Test
+  void aNameUsedTwiceKeepsItsLastValue() {
+    assertSameText(
+        "data",
+        List.of("id", "name", "id"),
+        new Object[] {1L, "first", 99L},
+        new Object[] {2L, "second", null});
+  }
+
+  @Test
+  void namesAndTheBlockNameAreEscapedToo() {
+    assertSameText(
+        "block \"name\" / with \\ things",
+        List.of("a/b", "quote\"d", "é", ""),
+        new Object[] {1L, 2L, 3L, 4L});
+  }
+
+  @Test
+  void noRowsAndOneRowAndNoFields() {
+    assertSameText("data", List.of("id"));
+    assertSameText("", List.of("id"), new Object[] {1L});
+    assertSameText("data", List.of(), new Object[] {}, new Object[] {});
+  }
+}

Reply via email to