Forum Discussion
ddangler
9 years agoNew Contributor III
Thanks for looking into it. One followup question. When I tried this, it is double quoting even numbers :
Any help on this?
tstack
9 years agoFormer Employee
In the arrow function, you’ll probably want to use parseFloat() to attempt to convert the string to a number. If parsing the string fails, a NaN will be returned, so you can use a logical-or operator to fallback to the original value. Here it is in code:
parseFloat(value) || value
Here is the updated expression:
jsonPath($.mapValues((value, key) => { value: parseFloat(value) || value, id: parseInt(key.match(/\d+/)[0]) }), "$*")
- ddangler9 years agoNew Contributor III
I appreciate the prompt response and it worked. You saved me again 🙂