Currently forming the JSON using the below string in java , will be used in multithreading environment and values will be dynamic after passing the values this JSON will be posted to the 3 rd party web service
"{"
+ " \"test\": {"
+ " \"testCont\": {"
+ " \"size\": {"
+ " \"size\": " + size +","
+ " \"number\": " + number
+ " }"
+ " },"
+ " \"testDate\": {"
+ " \"testAccount\": {"
+ " \"name\": ["
+ testMethod.getName()
+ " ],"
+ " \"school\": {"
+ " \"schoolIdentity\": ["
+ testMethod.schoolIdentity()
+ " ]"
+ " }"
+ " }"
+ " }"
+ " }"
+ "}"
I am aware that using String concatenation will create unnecessary objects in heap
Can some one please tell me the most efficient way to create which will not create additional objects in heap and help to gain performance ?