-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement
json_encode()
user function (#2352)
* implemented json_encode() Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com> * fixed json_encode and fixed tests Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com> * ignore this Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com> * bug fixes Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com> * bug fixes Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com> --------- Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com>
- Loading branch information
Showing
2 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
CommandLine/testing/SimpleTests/json_encode_test.sog/create.edl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var async_load = ds_map_create(); | ||
|
||
//ds_map_add(async_load, "entries", "{\n\"entries\":[\n{\"name\":\"TomasJPereyra\",\"score\":1,\"rank\":1,\"userID\":\"@i64@1234$i64$\"},\n{\"name\":\"Benal\",\"score\":254,\"rank\":10,\"userID\":\"@i64@12345$i64$\",\"data\":\"SEJlbmFsIHdhcyBoZXJlIDopAAA=\"}\n\n]\n}\n"); | ||
ds_map_add(async_load, "entries", '{\n\"entries\":[\n{\"name\":\"TomasJPereyra\",\"score\":1,\"rank\":1,\"userID\":\"@i64@1234$i64$\"},\n{\"name\":\"Benal\",\"score\":254,\"rank\":10,\"userID\":\"@i64@12345$i64$\",\"data\":\"SEJlbmFsIHdhcyBoZXJlIDopAAA=\"}\n\n]\n}\n'); | ||
ds_map_add(async_load, "lb_name", "YYLeaderboard_10\/29\/21--"); | ||
ds_map_add(async_load, "event_type", "leaderboard_download"); | ||
ds_map_add(async_load, "id", 5.0); | ||
ds_map_add(async_load, "num_entries", 2.0); | ||
ds_map_add(async_load, "status", 1.0); | ||
|
||
var decoded_string = json_encode(async_load); | ||
|
||
var ds_map = json_decode(decoded_string); | ||
|
||
gtest_assert_eq(ds_map_size(ds_map), 6); | ||
|
||
gtest_assert_eq(ds_map_exists(ds_map, "entries"), true); | ||
gtest_assert_eq(ds_map_exists(ds_map, "lb_name"), true); | ||
gtest_assert_eq(ds_map_exists(ds_map, "event_type"), true); | ||
gtest_assert_eq(ds_map_exists(ds_map, "id"), true); | ||
gtest_assert_eq(ds_map_exists(ds_map, "num_entries"), true); | ||
gtest_assert_eq(ds_map_exists(ds_map, "status"), true); | ||
|
||
gtest_assert_eq(ds_map_exists(ds_map, "test_not_exist"), false); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters