From 08cd4332dbb662f23d4b6f7e0d28b2a8e139286d Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Fri, 18 Dec 2020 12:34:05 +0000 Subject: [PATCH] json decode_map encode_map --- vlib/v/gen/json.v | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vlib/v/gen/json.v b/vlib/v/gen/json.v index 7ed319fe6d6ab5..11b4c98134f007 100644 --- a/vlib/v/gen/json.v +++ b/vlib/v/gen/json.v @@ -263,7 +263,8 @@ fn (mut g Gen) decode_map(key_type table.Type, value_type table.Type) string { cJSON_ArrayForEach(jsval, root) { $s - map_set(&res, tos2( (byteptr) jsval->string ) , &val ); + string key = tos2( (byteptr) jsval->string ); + map_set_1(&res, &key, &val); } ' } @@ -286,7 +287,7 @@ fn (mut g Gen) encode_map(key_type table.Type, value_type table.Type) string { array_$styp $keys_tmp = map_keys(&val); for (int i = 0; i < ${keys_tmp}.len; ++i) { $key - cJSON_AddItemToObject(o, (char*) key.str, $fn_name_v ( *($styp_v*) map_get(val, key, &($styp_v[]) { $zero } ) ) ); + cJSON_AddItemToObject(o, (char*) key.str, $fn_name_v ( *($styp_v*) map_get_1(&val, &key, &($styp_v[]) { $zero } ) ) ); } array_free(&$keys_tmp); '