nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e3848b4
)
json: deserialize Maps keys first, in the same order as they are written
author
Alexis Laferrière
<alexis.laf@xymus.net>
Mon, 24 Jul 2017 14:35:27 +0000
(10:35 -0400)
committer
Alexis Laferrière
<alexis.laf@xymus.net>
Wed, 26 Jul 2017 15:03:45 +0000
(11:03 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
lib/json/serialization_read.nit
patch
|
blob
|
history
diff --git
a/lib/json/serialization_read.nit
b/lib/json/serialization_read.nit
index
7d40a88
..
1673687
100644
(file)
--- a/
lib/json/serialization_read.nit
+++ b/
lib/json/serialization_read.nit
@@
-518,6
+518,8
@@
redef class Map[K, V]
return
end
+ # First, convert all keys to follow the order of the serialization
+ var converted_keys = new Array[K]
for i in length.times do
var key = v.convert_object(keys[i], keys_type_name)
@@
-526,6
+528,12
@@
redef class Map[K, V]
continue
end
+ converted_keys.add key
+ end
+
+ # Then convert the values and build the map
+ for i in length.times do
+ var key = converted_keys[i]
var value = v.convert_object(values[i], values_type_name)
if not value isa V then