String addition with a const string reference

I have a method that looks as follows which is being run on an ATMEGA328P:

String Input::ReturnInputObjectFromValuesArray(const String& valuesArray, const String& miscDetailsToAppend) const
{			
   // start wrapper
   String outputString = "{";
    
       // print input number since these will be separated on send possibly
       outputString += "\"" + String(INPUT_NUMBER_KEY) + "\":" + String(this->InputIndexInTotalInputs) + ",";				           		
    
       outputString += "\"" + String(INPUT_VALUES_KEY) + "\":" + valuesArray;
    
       outputString += "}";
    
   return outputString;
}

When this outputs, it seems to ignore that line right when I try to add any of the parameter values which are string constants by reference as shown. If I comment out/remove the + valuesArray it runs fine. The output just returns an empty string once the addition is attempted.

I should also note that if I add a Serial.println(valuesArray); anywhere, it'll print perfectly fine so the value is definitely there. I also tried outputString.concat(valuesArray) but that returns false meaning that it failed.

I've also tried separating out the additions rather than doing them all inline as I've read that adding different types in the same line can be risky.

Am I performing this addition incorrectly/is there a better way to do it? I'm open to any suggestions if there are better ways to attempt this. Thanks in advance.

It sounds like valuesArray is an array and if so you can't just concatenate it onto a String like that

UKHeliBob:
It sounds like valuesArray is an array and if so you can't just concatenate it onto a String like that

That was my bad naming on that one. It's just a String. The String is a JSON array if you look at it when it prints, but it is a String object. Basically the String looks like this: "[[0,4],[5,2]]" or variations of that

What does outputString look like just before you return it ?

It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. This can happen after the program has been running perfectly for some time. Just use cstrings - char arrays terminated with '\0' (NULL).

...R