Skip to content

Commit 7634657

Browse files
authored
JIRA-WDT-397 Format strings in JSON lists with double-quotes (#551)
1 parent cf8e70d commit 7634657

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

core/src/main/python/wlsdeploy/json/json_translator.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
55
This model provider translation classes that convert between JSON and Python Dictionaries.
@@ -170,13 +170,34 @@ def _write_dictionary_to_json_file(self, dictionary, writer, indent=''):
170170
writer.write(indent + '"' + _quote_embedded_quotes(key) + '" : ')
171171
if isinstance(value, dict):
172172
self._write_dictionary_to_json_file(value, writer, indent)
173+
elif isinstance(value, list):
174+
self._write_list_to_json_file(value, writer, indent)
173175
else:
174176
writer.write(_format_json_value(value))
175177
writer.println()
176178
writer.write(end_indent + _end_dict)
177179

178180
return
179181

182+
def _write_list_to_json_file(self, alist, writer, indent=''):
183+
"""
184+
Write the python list in json syntax using the provided writer stream.
185+
:param alist: python list to convert to json syntax
186+
:param writer: where to write the list into json syntax
187+
:param indent: current string indention of the json syntax. If not provided, indent is an empty string
188+
"""
189+
writer.write('[')
190+
end_line = ''
191+
list_indent = indent + self._indent_unit
192+
for value in alist:
193+
writer.write(end_line)
194+
writer.println()
195+
writer.write(list_indent)
196+
writer.write(_format_json_value(value))
197+
end_line = ','
198+
writer.println()
199+
writer.write(indent + ']')
200+
180201
def _close_streams(self, fos, writer):
181202
"""
182203
Close the correct output stream.

0 commit comments

Comments
 (0)