Except for Replace in convert_JSON
@@ -44,9 +44,10 @@ def natural_sort(l, field=None):
def convert_JSON(j):
""" Recursively convert CamelCase keys to snake_case.
- From: https://stackoverflow.com/questions/17156078/converting-identifier-naming-between-camelcase-and-underscores-during-json-seria
+ From: https://stackoverflow.com/questions/17156078/
+ converting-identifier-naming-between-camelcase-and-
+ underscores-during-json-seria
"""
-
def camel_to_snake(s):
a = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))')
return a.sub(r'_\1', s).lower()
@@ -66,7 +67,8 @@ def convert_JSON(j):
for k, value in j.items():
newK = camel_to_snake(k)
- if isinstance(value, dict):
+ # Replace transformation uses a dict, so skip lower-casing
+ if isinstance(value, dict) and k != 'Replace':
out[newK] = convert_JSON(value)
elif isinstance(value, list):
out[newK] = convertArray(value)
