2020from  wlsdeploy .logging .platform_logger  import  PlatformLogger 
2121import  wlsdeploy .exception .exception_helper  as  exception_helper 
2222
23+ # Unlike with yaml files, JSON files do not allow comments. remove from file 
24+ COMMENT_MATCH  =  '# - ' 
2325
2426class  JsonToPython (object ):
2527    """ 
@@ -155,6 +157,7 @@ def _write_dictionary_to_json_file(self, dictionary, writer, indent=''):
155157        :param writer: where to write the dictionary into json syntax 
156158        :param indent: current string indention of the json syntax. If not provided, indent is an empty string 
157159        """ 
160+         _method_name  =  '_write_dictionary_to_json_file' 
158161        _start_dict  =  '{' 
159162        _end_dict  =  '}' 
160163
@@ -167,15 +170,18 @@ def _write_dictionary_to_json_file(self, dictionary, writer, indent=''):
167170
168171        indent  +=  self ._indent_unit 
169172        for  key , value  in  dictionary .iteritems ():
170-             writer .println (end_line )
171-             end_line  =  ',' 
172-             writer .write (indent  +  '"'  +  _escape_text (key ) +  '" : ' )
173-             if  isinstance (value , dict ):
174-                 self ._write_dictionary_to_json_file (value , writer , indent )
175-             elif  isinstance (value , list ):
176-                 self ._write_list_to_json_file (value , writer , indent )
173+             if  isinstance (key , basestring ) and  key .startswith (COMMENT_MATCH ):
174+                 self ._logger .finer ('WLSDPLY-01714' , key , class_name = self ._class_name , method_name = _method_name )
177175            else :
178-                 writer .write (_format_json_value (value ))
176+                 writer .println (end_line )
177+                 end_line  =  ',' 
178+                 writer .write (indent  +  '"'  +  _escape_text (key ) +  '" : ' )
179+                 if  isinstance (value , dict ):
180+                     self ._write_dictionary_to_json_file (value , writer , indent )
181+                 elif  isinstance (value , list ):
182+                     self ._write_list_to_json_file (value , writer , indent )
183+                 else :
184+                     writer .write (_format_json_value (value ))
179185        writer .println ()
180186        writer .write (end_indent  +  _end_dict )
181187
0 commit comments