11note
22 description : " Summary description for {SE_BUILD_VALUE_JSON_CONVERTER}."
3- author : " "
43 date : " $Date$"
54 revision : " $Revision$"
65
@@ -25,48 +24,58 @@ feature -- Access
2524
2625feature -- Conversion
2726
28- from_json (j : like to_json ): detachable like object
27+ from_json (a_json : detachable JSON_VALUE ; ctx : JSON_DESERIALIZER_CONTEXT ; a_type : detachable TYPE [ detachable ANY ] ): detachable like object
2928 do
30- create Result .make_empty
31- if attached {STRING_ 32 } json_to_object (j .item (version_key ),Void ) as l_item then
32- Result .set_version (l_item )
29+ if attached {JSON_OBJECT } a_json as j then
30+ create Result .make_empty
31+ if attached {JSON_STRING } j .item (version_key ) as l_item then
32+ Result .set_version (l_item .unescaped_string_ 32 )
33+ end
34+ if attached {JSON_STRING } j .item (revision_key ) as l_item then
35+ Result .set_revision (l_item .unescaped_string_ 32 )
36+ end
37+ if attached {JSON_STRING } j .item (time_key ) as l_item then
38+ Result .set_time (l_item .unescaped_string_ 32 )
39+ end
3340 end
34- if attached {STRING_ 32 } json_to_object (j .item (revision_key ), Void ) as l_item then
35- Result .set_revision (l_item )
36- end
37- if attached {STRING_ 32 } json_to_object (j .item (time_key ),Void ) as l_item then
38- Result .set_time (l_item )
39- end
40-
41-
42-
4341 end
4442
45- to_json (o : like object ): JSON_OBJECT
43+ to_json (obj : detachable ANY ; ctx : JSON_SERIALIZER_CONTEXT ): JSON_VALUE
44+ local
45+ jo : JSON_OBJECT
4646 do
47- create Result .make
48- Result .put (json .value (o .version ), version_key )
49- Result .put (json .value (o .revision ), revision_key )
50- Result .put (json .value (o .time ), time_key )
47+ if attached {SE_BUILD_VALUE } obj as o then
48+ create jo .make_with_capacity (3 )
49+ if attached o .version as l_version then
50+ jo .put_string (l_version , version_key )
51+ end
52+ if attached o .revision as l_revision then
53+ jo .put_string (l_revision , revision_key )
54+ end
55+ if attached o .time as l_time then
56+ jo .put_string (l_time , time_key )
57+ end
58+ Result := jo
59+ else
60+ create {JSON_NULL } Result
61+ end
5162 end
5263
5364feature {NONE } -- Implementation
5465
55-
56-
5766 version_key : JSON_STRING
5867 once
59- create Result .make_json (" version" )
68+ create Result .make_from_string (" version" )
6069 end
6170
6271 time_key : JSON_STRING
6372 once
64- create Result .make_json (" time" )
73+ create Result .make_from_string (" time" )
6574 end
6675
6776 revision_key : JSON_STRING
6877 once
69- create Result .make_json (" revision" )
78+ create Result .make_from_string (" revision" )
7079 end
7180
7281end
0 commit comments