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

Bug manipulating LazyArray #25

Open
SGE66 opened this issue Apr 2, 2022 · 0 comments
Open

Bug manipulating LazyArray #25

SGE66 opened this issue Apr 2, 2022 · 0 comments

Comments

@SGE66
Copy link

SGE66 commented Apr 2, 2022

Execute following code:

        LazyArray records = new LazyArray("[{\"id\": \"20\"}]");
        LazyArray activities =  new LazyArray("[{\"id\": \"30\"}]");
        
        LazyArray tmp = new LazyArray();
        for (int i = 0; i < records.length(); i++) {
            tmp.put(records.getJSONObject(i));
        }
        for (int i = 0; i < activities.length(); i++) {
            tmp.put(activities.getJSONObject(i));
        }
                
        System.out.println("-- tmp (no pad) -- ");
        System.out.println(tmp.length());
        System.out.println(tmp.toString());
        
        System.out.println("-- tmp (with padding) -- ");
        System.out.println(tmp.length());
        System.out.println(tmp.toString(2));

        System.out.println("-- records (no pad) -- ");
        System.out.println(records.length());
        System.out.println(records.toString());
        
        System.out.println("-- records (with padding) -- ");
        System.out.println(records.length());
        System.out.println(records.toString(2));
        
        System.out.println("-- activities -- ");
        System.out.println("-- activities (no pad) -- ");
        System.out.println(activities.length());
        System.out.println(activities.toString());
        
        System.out.println("-- activities (with padding) -- ");
        System.out.println(activities.length());
        System.out.println(activities.toString(2));

Output:

-- tmp (no pad) -- 
2
[{"id": "20"},{"id": "30"}]
-- tmp (with padding) -- 
2
[
  {
    "id":"20"
  },
  {
    "id":"30"
  }
]
-- records (no pad) -- 
1
[{"id": "20"}]
-- records (with padding) -- 
1
[
  {
    "id":"20"
  },
  {
    "id":"30"
  }
]
-- activities -- 
-- activities (no pad) -- 
1
[{"id": "30"}]
-- activities (with padding) -- 
1
[
  {
    "id":"30"
  }
]

The output for the records (with padding) is wrong: length = 1 is correct but extra entry added when padded !?

-- records (with padding) -- 
1
[
  {
    "id":"20"
  },
  {
    "id":"30"
  }
]

Any ideas ho to solve ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant