I have some objects that I'm parsing from json using native browser implementations. Some of the objects' properties are numbers. For the moment, the numbers are parse from json as strings and I use parseInt to cast the string to the int I need.
The problem is that I've got 23 objects I do this with and overall about 80 properties that I'm parsing to ints like this:
if (TheObject && TheObject.TheProperty) {
TheObject.TheProperty = parseInt(TheObject.TheProperty, 10);
}
There are many lines of code that look very similar. Is there a way using prototypes or something to change the way the JSON.parse function works so that each time the parser runs it checks to see if a string property is actually an int and if so cast it directly as such?
Thanks.