diff --git a/passerelle/utils/json.py b/passerelle/utils/json.py index 7b8c9401..597d9e1b 100644 --- a/passerelle/utils/json.py +++ b/passerelle/utils/json.py @@ -29,6 +29,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import re from passerelle.utils.validation import is_number @@ -49,10 +50,22 @@ def unflatten(d, separator=FLATTEN_SEPARATOR): # ok d is a dict - def map_digits(l): - return [int(x) if is_number(x) else x for x in l] + def split_key(key): + def map_key(x): + if is_number(x): + return int(x) + elif isinstance(x, str): + return x.replace('%s%s' % (FLATTEN_SEPARATOR, FLATTEN_SEPARATOR), FLATTEN_SEPARATOR) + return x - keys = [(map_digits(key.split(separator)), key) for key in d] + return [ + map_key(x) + for x in re.split( + r'(?