Al: JsonArray.IndexOf returns -1 when searching for added values

Created on 23 Jul 2019  Â·  4Comments  Â·  Source: microsoft/AL

Describe the bug
JsonArray.IndexOf doesn't seem to find the index of values (specifically Integers previously added). The debugger shows that the array is populated like (e.g. [1] or [1, 2]) but searching for their indexes always returns -1.

To Reproduce

  1. Run the following procedure:
local procedure foo()
var
    arr: JsonArray;
begin
    arr.Add(5);
    Message(Format(arr.IndexOf(5)));
end;

This is just a simple sample but I've been trying to find indexes of Texts (you could just do Format(1)), JsonToken (only works after using JsonArray.Get, but that assumes you know the index either way), JsonVar and so on.

Expected behavior
Message prompts with the correct index 0.

Screenshots
image

Versions:

  • AL Language: 3.0.152816
  • Business Central: 14.0.32600.0
bug json platform-api ships-in-future-update

All 4 comments

I have this issue, too

Same issue here. Do you guys know of any workaround? Looping I guess? :-)

loop-de-loop.

The fix for this issue has been checked in to the master branch. It will be available in the bcinsider.azurecr.io/bcsandbox-master Docker image starting from platform build number 37631 and VS Code Extension Version 5.0.192301.

If you don’t have access to these images you need to become part of the Ready2Go program: aka.ms/readytogo

For more details on code branches and docker images please read:
https://blogs.msdn.microsoft.com/nav/2018/05/03/al-developer-previews-multiple-releases-and-github/
https://blogs.msdn.microsoft.com/freddyk/2018/04/16/which-docker-image-is-the-right-for-you/

Was this page helpful?
0 / 5 - 0 ratings