restore initial json parsing attempt to loader

fixes issues with extra vars json strings not being parsed correctly by the yaml parser
pull/13135/merge
Brian Coca 9 years ago
parent 7160b40ab1
commit ea5e089056

@ -72,8 +72,12 @@ class DataLoader():
Creates a python datastructure from the given data, which can be either
a JSON or YAML string.
'''
# YAML parser will take JSON as it is a subset.
new_data = None
try:
# we first try to load this data as JSON
new_data = json.loads(data)
except:
# must not be JSON, let the rest try
if isinstance(data, AnsibleUnicode):
# The PyYAML's libyaml bindings use PyUnicode_CheckExact so
# they are unable to cope with our subclass.
@ -90,6 +94,7 @@ class DataLoader():
if isinstance(data, AnsibleUnicode):
new_data = AnsibleUnicode(new_data)
new_data.ansible_pos = data.ansible_pos
return new_data
def load_from_file(self, file_name):

Loading…
Cancel
Save