diff --git a/python/libraries/json.py b/python/libraries/json.py index ef692864..21aa5eec 100644 --- a/python/libraries/json.py +++ b/python/libraries/json.py @@ -101,17 +101,21 @@ def parseSafe(string): def convert_float_to_int(value): if isinstance(value, float): if value % 1 == 0: - return round(value) - return value - elif not isinstance(value, dict): - return value - - for i in value.keys(): - if isinstance(value[i], dict): - value[i] = convert_float_to_int(value[i]) - elif isinstance(value[i], float): - if value[i] % 1 == 0: - value[i] = round(value[i]) + value = round(value) + elif isinstance(value, dict): + for i in value.keys(): + if isinstance(value[i], dict) or isinstance(value[i], list): + value[i] = convert_float_to_int(value[i]) + elif isinstance(value[i], float): + if value[i] % 1 == 0: + value[i] = round(value[i]) + elif isinstance(value, list): + for i in range(len(value)): + if isinstance(value[i], dict) or isinstance(value[i], list): + value[i] = convert_float_to_int(value[i]) + elif isinstance(value[i], float): + if value[i] % 1 == 0: + value[i] = round(value[i]) return value diff --git a/python/run.n b/python/run.n index cba1df78..f44a951d 100644 --- a/python/run.n +++ b/python/run.n @@ -3,7 +3,7 @@ print(\n + "eee") print(split(\{.}, "this.is.a.test")) import json -print(json.stringify(json.object(mapFrom([ +print(json.stringify(json.array([json.object(mapFrom([ ("op", json.number(2.0)), ("d", json.object(mapFrom([ ("token", json.string("dingus")), @@ -14,6 +14,8 @@ print(json.stringify(json.object(mapFrom([ ("$device", json.string("none")) ]))), ]))) -])))) +])), +json.number(1.0), +json.string("ping")]))) -print(json.stringify(json.string("ping"))) \ No newline at end of file +print(json.stringify(json.string("bingus"))) \ No newline at end of file