|
|
|
@ -72,8 +72,12 @@ class DataLoader():
|
|
|
|
Creates a python datastructure from the given data, which can be either
|
|
|
|
Creates a python datastructure from the given data, which can be either
|
|
|
|
a JSON or YAML string.
|
|
|
|
a JSON or YAML string.
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
new_data = None
|
|
|
|
# YAML parser will take JSON as it is a subset.
|
|
|
|
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):
|
|
|
|
if isinstance(data, AnsibleUnicode):
|
|
|
|
# The PyYAML's libyaml bindings use PyUnicode_CheckExact so
|
|
|
|
# The PyYAML's libyaml bindings use PyUnicode_CheckExact so
|
|
|
|
# they are unable to cope with our subclass.
|
|
|
|
# they are unable to cope with our subclass.
|
|
|
|
@ -90,6 +94,7 @@ class DataLoader():
|
|
|
|
if isinstance(data, AnsibleUnicode):
|
|
|
|
if isinstance(data, AnsibleUnicode):
|
|
|
|
new_data = AnsibleUnicode(new_data)
|
|
|
|
new_data = AnsibleUnicode(new_data)
|
|
|
|
new_data.ansible_pos = data.ansible_pos
|
|
|
|
new_data.ansible_pos = data.ansible_pos
|
|
|
|
|
|
|
|
|
|
|
|
return new_data
|
|
|
|
return new_data
|
|
|
|
|
|
|
|
|
|
|
|
def load_from_file(self, file_name):
|
|
|
|
def load_from_file(self, file_name):
|
|
|
|
|