def _load_category_file(self, category_file_path):
     category_input_stream = FileUtils.getResourceAsStream(
         category_file_path)
     self.assertNotEquals(category_input_stream, None)
     json_translator = JsonStreamTranslator(category_file_path,
                                            category_input_stream)
     return json_translator.parse()
 def testEscapeBackslash(self):
     # JSON "xy\\.z" should become String "xy\.z"
     text = "{ \"abc\": \"xy\\\\.z\" }"
     stream = ByteArrayInputStream(text.encode('utf-8'))
     json_translator = JsonStreamTranslator("String", stream)
     result = json_translator.parse()
     abc = result['abc']
     self.assertEquals("xy\\.z", abc, "Should be single slash")
Exemplo n.º 3
0
def get_dictionary_from_json_file(json_file_name):
    """
    Load the dictionary with the generated folder and attribute information from the provided location.
    :param json_file_name: path and name of the generated file
    :return: loaded dictionary or None if unable to parse and load the file
    """
    _method_name = 'get_dictionary_from_json_file'
    __logger.entering(json_file_name,
                      class_name=CLASS_NAME,
                      method_name=_method_name)
    print 'THE FILE NAME IS ', json_file_name
    json_input_stream = FileInputStream(File(json_file_name))
    json_translator = JsonStreamTranslator(json_file_name, json_input_stream)
    dictionary = None
    try:
        dictionary = json_translator.parse()
    except JsonException, je:
        __logger.severe('WLSDPLYST-01317',
                        json_file_name,
                        je.getLocalizedMessage(),
                        class_name=CLASS_NAME,
                        method_name=_method_name)