restore initial json parsing attempt to loader
fixes issues with extra vars json strings not being parsed correctly by the yaml parser
This commit is contained in:
parent
7160b40ab1
commit
ea5e089056
1 changed files with 21 additions and 16 deletions
|
@ -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):
|
||||||
|
|
Loading…
Reference in a new issue