Apply pretty print tool.
Apply on each class in test suite and library.
This commit is contained in:
@@ -1,73 +1,74 @@
|
||||
note
|
||||
description: "A JSON converter for BOOK"
|
||||
author: "Paul Cohen"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
description: "A JSON converter for BOOK"
|
||||
author: "Paul Cohen"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
JSON_BOOK_CONVERTER
|
||||
|
||||
inherit
|
||||
JSON_CONVERTER
|
||||
|
||||
JSON_CONVERTER
|
||||
|
||||
create
|
||||
make
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
local
|
||||
ucs: STRING_32
|
||||
a: AUTHOR
|
||||
do
|
||||
create ucs.make_from_string ("")
|
||||
create a.make (ucs)
|
||||
create object.make (ucs, a, ucs)
|
||||
end
|
||||
make
|
||||
local
|
||||
ucs: STRING_32
|
||||
a: AUTHOR
|
||||
do
|
||||
create ucs.make_from_string ("")
|
||||
create a.make (ucs)
|
||||
create object.make (ucs, a, ucs)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
object: BOOK
|
||||
object: BOOK
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
from_json (j: like to_json): detachable like object
|
||||
do
|
||||
if
|
||||
from_json (j: like to_json): detachable like object
|
||||
do
|
||||
if
|
||||
attached {STRING_32} json.object (j.item (title_key), Void) as l_title and
|
||||
attached {STRING_32} json.object (j.item (isbn_key), Void) as l_isbn and
|
||||
attached {AUTHOR} json.object (j.item (author_key), "AUTHOR") as l_author
|
||||
then
|
||||
then
|
||||
create Result.make (l_title, l_author, l_isbn)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
to_json (o: like object): JSON_OBJECT
|
||||
do
|
||||
create Result.make
|
||||
Result.put (json.value (o.title), title_key)
|
||||
Result.put (json.value (o.isbn), isbn_key)
|
||||
Result.put (json.value (o.author), author_key)
|
||||
end
|
||||
to_json (o: like object): JSON_OBJECT
|
||||
do
|
||||
create Result.make
|
||||
Result.put (json.value (o.title), title_key)
|
||||
Result.put (json.value (o.isbn), isbn_key)
|
||||
Result.put (json.value (o.author), author_key)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
title_key: JSON_STRING
|
||||
title_key: JSON_STRING
|
||||
-- Book's title label.
|
||||
once
|
||||
create Result.make_json ("title")
|
||||
end
|
||||
once
|
||||
create Result.make_json ("title")
|
||||
end
|
||||
|
||||
isbn_key: JSON_STRING
|
||||
isbn_key: JSON_STRING
|
||||
-- Book ISBN label.
|
||||
once
|
||||
create Result.make_json ("isbn")
|
||||
end
|
||||
once
|
||||
create Result.make_json ("isbn")
|
||||
end
|
||||
|
||||
author_key: JSON_STRING
|
||||
author_key: JSON_STRING
|
||||
-- Author label.
|
||||
once
|
||||
create Result.make_json ("author")
|
||||
end
|
||||
once
|
||||
create Result.make_json ("author")
|
||||
end
|
||||
|
||||
end -- class JSON_BOOK_CONVERTER
|
||||
|
||||
Reference in New Issue
Block a user