I have a multiple different JSON requests of data that is being passed into my Go app that contains numbers in different formats. An example of a request is as follows:
{
"stringData":"123456",
"intData": 123456,
"floatData": 123456.0
}
Is there a way to unmarshal this data into the type which is determined by the JSON data. For example, string data would be "123456", int data would be 123456 and float data would be 123456.0. I do not have structs defined for these JSON objects and creating structs for these are not an option.
I have looked at the decoder.UseNumber() method to convert the data into strings, but I don't know how to handle the difference between stringData and intData after that.