Skip to content

Commit

Permalink
json decode_map encode_map
Browse files Browse the repository at this point in the history
  • Loading branch information
ntrel committed Dec 18, 2020
1 parent 9c68947 commit bc6cb4b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions vlib/v/gen/json.v
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
'
}
Expand All @@ -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);
'
Expand Down

0 comments on commit bc6cb4b

Please sign in to comment.