I'm trying to select all of the lowest tier(in the "nest") possible values that are numbers, and not strings, in a nested json. This will include arrays and objects. Currently, im using this code
(?<=:)\s*([+-]?\d+(?:\.\d*(?:E-?\d+)?)?)\b\s*(?=(?:\{|,)\s*\"[^\"]*\":)
(which is mostly from this question)
and it works, if it isn't the last value of an object, or in a list. My main problem is, that it can be fooled. for example, if i have these two "a":":1,", ":":a
key-value pairs next to eachother, it sees the number 1 as a value, except that the actual value is ":1,". How can i make a foolproof system for this?
Im excpecting it to not select anything, that couldn't be an integer or a float. I would like to keep the middle part of my original regex, beacuse it also needs to work with scientific notations.