eJson initial import
This commit is contained in:
35
json/json_file_reader.e
Normal file
35
json/json_file_reader.e
Normal file
@@ -0,0 +1,35 @@
|
||||
indexing
|
||||
description: "Objects that ..."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
JSON_FILE_READER
|
||||
|
||||
feature -- Access
|
||||
read_json_from(a_path:STRING):STRING is
|
||||
local
|
||||
l_file: PLAIN_TEXT_FILE
|
||||
template_content:STRING
|
||||
do
|
||||
|
||||
create l_file.make (a_path)
|
||||
-- We perform several checks until we make a real attempt to open the file.
|
||||
if not l_file.exists then
|
||||
print ("error: '" + a_path + "' does not exist%N")
|
||||
else
|
||||
if not l_file.is_readable then
|
||||
print ("error: '" + a_path + "' is not readable.%N")
|
||||
else
|
||||
l_file.open_read
|
||||
create template_content.make_empty
|
||||
l_file.read_stream (l_file.count)
|
||||
template_content.append (l_file.last_string.twin)
|
||||
Result := template_content
|
||||
l_file.close
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user