I'm creating a search component for a JSON that's deserialize and I want to add a pagination that returns by 10. Is it possible to add a limit and offset in the return?


I'm searching in the orders for "approved orders" and in the order record there are 20 records now I want to display them by 10 and the other 10 is on the next page. Is it possible? this orders are from a json field which I deserialized.

Thank you.

1 Answer 1


Interesting.. Unfortunately you can't use limit and offset with JSON deserialize. But you can do the same programmatically, iterate deserialize object and filter records by 10.

If my understanding is right, you are getting a JSON which may contain multiple records but you need to add pagination there?

you can use traditional for loop in apex so that you can easily do this req:

integer i,offSet=0,recordCount=10;
list<yourtype>pageinateApprovedorders = new list<yourtype>()
//approvedordersList is a JSON deserialized list
for (i=offSet;i<approvedordersList.size() && i<offSet+recordCount ; i++)

See the example "paginateApprovedorders" list you will get the 10 records, you make this as separate method and dynamically you can pass limit and offset to the method.

  • Hi Nishad yes you're correct I have a field that contains a json text and it can handle multiple records. I'll try that one. Thank you.
    – Atoc
    Commented Sep 24, 2019 at 12:38
  • @Atoc Please let me know the outcome Commented Sep 24, 2019 at 12:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .