0

I'm trying to make a json object with the same order as the inputNames list.

I tried this:

            JSONObject jsonInputs = new JSONObject();
            String[] params = tf.params.split("\\|");
            //get the input descriptions
            List<TestInput> inputNames = TestInput.getInputs(testCaseName);
            for (int i = (params.length - 1); i >= 0; i--) {
                jsonInputs.put(inputNames.get(i).getName(), params[i]);
            }
            jsonTest.put("inputs", jsonInputs);

and

 JSONObject jsonInputs = new JSONObject();
            String[] params = tf.params.split("\\|");
            //get the input descriptions
            List<TestInput> inputNames = TestInput.getInputs(testCaseName);
            for (int i = 0; i < params.length; i++) {
                jsonInputs.put(inputNames.get(i).getName(), params[i]);
            }
            jsonTest.put("inputs", jsonInputs);

And the result of the jsonInputs the same. It's the reverse order of inputNames

How do I make it stay in the order that is created?

0 Answers0