You cannot directly do so. As a workaround, can manually parse the JSON with JSON.deserializeUntyped or JSONParser, then do the conversion manually for each value.
Here's an example:
Object stringifyAll(Object value) {
if(value instanceOf Map<String, Object>) {
System.debug('parsing map');
Map<String, Object> temp = (Map<String, Object>)value;
for(String key: temp.keySet()) {
temp.put(key, stringifyAll(temp.get(key)));
}
return temp;
}
if(value instanceOf List<Object>) {
system.debug('parsing list');
List<Object> temp = (List<Object>)value;
for(Integer i = 0, s = temp.size(); i < s; i++) {
temp[i] = stringifyAll(temp[i]);
}
return temp;
}
return value==null?null:value+'';
}
Which is called as:
Object results = stringifyAll(
JSON.deserializeUntyped(jsonSource)
};
Or, if you want it back in a JSON string:
String jsonResults = JSON.serialize(
stringifyAll(
JSON.deserializeUntyped(jsonSource)
)
);
If you want to retain null values as null (instead of the string "null"), change the last line to:
return value == null? null: ''+value;