Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json extension not converting to DS map correctly #2354

Closed
k0T0z opened this issue Aug 15, 2023 · 0 comments · Fixed by #2355
Closed

Json extension not converting to DS map correctly #2354

k0T0z opened this issue Aug 15, 2023 · 0 comments · Fixed by #2355

Comments

@k0T0z
Copy link
Contributor

k0T0z commented Aug 15, 2023

The Json extension is working properly but it cannot convert to DS map correctly.

In order to reproduce, simply run the following SOG:

var json = '{"entries":{"entries":[{"name":"AlEw","score":196198,"rank":1,"userID":"1234"},{"name":"El Pice","score":58158,"rank":2,"userID":"12345"},{"name":"saif","score":505,"rank":3,"userID":"12346"},{"name":"Bucciarati (Couter55)","score":336,"rank":4,"userID":"12347"},{"name":"Haiyatin","score":236,"rank":5,"userID":"12348"},{"name":"Kaito","score":137,"rank":6,"userID":"12349"},{"name":"gamesadasteam","score":96,"rank":7,"userID":"123410"},{"name":"Bashkash2013","score":7,"rank":8,"userID":"123411"},{"name":"silveradagio","score":0,"rank":9,"userID":"123412"},{"name":"HappyStarXiXi","score":0,"rank":10,"userID":"123413"}]},"event_type":"leaderboard_download","id":0,"lb_name":"","num_entries":10,"status":0}';

var json_decoded = json_decode(json);

gtest_assert_eq(ds_map_size(json_decoded), 6);

gtest_assert_eq(ds_map_exists(json_decoded, "entries"), true);
gtest_assert_eq(ds_map_exists(json_decoded, "lb_name"), true);
gtest_assert_eq(ds_map_exists(json_decoded, "event_type"), true);
gtest_assert_eq(ds_map_exists(json_decoded, "id"), true);
gtest_assert_eq(ds_map_exists(json_decoded, "num_entries"), true);
gtest_assert_eq(ds_map_exists(json_decoded, "status"), true);

var entries = ds_map_find_value(json_decoded, "entries");
var list = ds_map_find_value(entries, "entries");

gtest_assert_eq(ds_list_size(list), 10);

The above SOG will fail, although it's convenient that the list of entries has 10 objects.

k0T0z added a commit to k0T0z/enigma-dev that referenced this issue Aug 16, 2023
Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com>
RobertBColton pushed a commit that referenced this issue Aug 16, 2023
* fixed json extension conversion to ds map and improved naming of some files

Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com>

* fix #2354

Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com>

---------

Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant