|
1 | 1 | submodule(dag_m) dag_s
|
2 | 2 | use assert_m, only : assert
|
3 |
| - use jsonff, only: & |
| 3 | + use rojff, only: & |
| 4 | + fallible_json_member_t, & |
| 5 | + fallible_json_object_t, & |
4 | 6 | fallible_json_string_t, &
|
5 | 7 | fallible_json_value_t, &
|
6 | 8 | json_array_t, &
|
7 |
| - json_element_t, & |
8 |
| - json_string_t, & |
9 |
| - parse_json |
10 |
| - use erloff, only : error_list_t |
| 9 | + json_element_t |
11 | 10 | use iso_fortran_env, only: iostat_end
|
12 |
| - use iso_varying_string, only : varying_string, operator(//), char, get, put, var_str |
| 11 | + use iso_varying_string, only : operator(//), char |
13 | 12 | use intrinsic_array_m, only : intrinsic_array_t
|
14 | 13 |
|
15 | 14 | implicit none
|
16 | 15 |
|
17 | 16 | type searched_and_ordered_t
|
18 | 17 | integer, allocatable, dimension(:) :: s, o
|
19 |
| - end type |
| 18 | + end type |
20 | 19 |
|
21 | 20 | contains
|
22 | 21 |
|
@@ -109,36 +108,32 @@ end function topological_sort
|
109 | 108 |
|
110 | 109 | module procedure construct_from_json
|
111 | 110 | type(fallible_json_value_t) :: maybe_vertices
|
112 |
| - type(error_list_t) errors |
113 | 111 |
|
114 |
| - maybe_vertices = json_object%get_element("vertices") |
115 |
| - errors = maybe_vertices%errors() |
116 |
| - call assert(.not. errors%has_any(), "dag_s construct_from_json: .not. errors%has_any()", char(errors%to_string())) |
| 112 | + maybe_vertices = json_object%get("vertices") |
| 113 | + call assert( & |
| 114 | + .not. maybe_vertices%errors%has_any(), & |
| 115 | + "dag_s construct_from_json: .not. errors%has_any()", & |
| 116 | + char(maybe_vertices%errors%to_string())) |
117 | 117 |
|
118 |
| - select type (vertices => maybe_vertices%value_()) |
| 118 | + select type (vertices => maybe_vertices%value_) |
119 | 119 | type is (json_array_t)
|
120 |
| - dag%vertices = vertex_t(vertices%get_elements()) |
| 120 | + dag%vertices = vertex_t(vertices%elements) |
121 | 121 |
|
122 | 122 | class default
|
123 |
| - call assert(.false., "dag%from_json: vertices was not an array", char(vertices%to_compact_string())) |
| 123 | + call assert(.false., "dag%from_json: vertices was not an array", vertices%to_compact_string()) |
124 | 124 | end select
|
125 | 125 | dag%order = topological_sort(dag)
|
126 | 126 | end procedure
|
127 | 127 |
|
128 |
| - module procedure to_json |
129 |
| - type(fallible_json_string_t) maybe_key |
130 |
| - type(error_list_t) errors |
131 |
| - type(json_string_t) vertices_key |
132 |
| - type(json_array_t) vertices_value |
| 128 | + module procedure to_json |
| 129 | + type(fallible_json_object_t) maybe_result |
133 | 130 |
|
134 |
| - maybe_key = fallible_json_string_t("vertices") |
135 |
| - errors = maybe_key%errors() |
136 |
| - call assert(.not. errors%has_any(), "dag%to_json: .not. errors%has_any()", char(errors%to_string())) |
137 |
| - |
138 |
| - vertices_value = json_array_t(json_element_t(self%vertices%to_json())) |
139 |
| - vertices_key = maybe_key%string() |
140 |
| - json_object = json_object_t([vertices_key], [json_element_t(vertices_value)]) |
141 |
| - end procedure |
| 131 | + maybe_result = fallible_json_object_t( & |
| 132 | + [ fallible_json_member_t("vertices", json_array_t(json_element_t(self%vertices%to_json()))) & |
| 133 | + ]) |
| 134 | + call assert(.not. maybe_result%errors%has_any(), "dag%to_json: .not. errors%has_any()", char(maybe_result%errors%to_string())) |
| 135 | + json_object = maybe_result%object |
| 136 | + end procedure |
142 | 137 |
|
143 | 138 | module procedure num_vertices
|
144 | 139 | num_vertices = size(self%vertices)
|
|
0 commit comments