How js-report input request size calculates?



  • Hi,
    I am sending data to js-report in json format which includes object, let's say:
    data = {
    object a: {object a has 1048 bytes size of data},
    object b: {object a has 69168 bytes size of data},
    object c: {object a has 38224 bytes size of data},
    object d: {object a has 76688 bytes size of data},
    object e: {object a has 200 bytes size of data},
    object f: {object a has 136 bytes size of data},
    object g: {object a has 136 bytes size of data},
    object h: {object a has 200 bytes size of data},
    object i: {object a has 200 bytes size of data},
    object j: {object a has 72 bytes size of data}
    }
    When I am counting manually the size of these data it's equal to 185,912 bytes(.2 Mb max.) but when this object goes to js-report, the size becomes approx 22Mb and because of that it gives error:
    Input request reached limit of 20971520 byte(s)(21 Mb)

    Now my question is how js-report calculates the input request size when we send a Json to js-report? How it's becoming 22Mb data? And Is there any way to reduce the size of the data?
    Please help me in understanding this.
    Thanks in advance!!



  • This is calculated by some library deep down the dependencies in jsreport. I think it is this one.

    To get the size I believe you need to serialize the whole rendering request and calculate number of bytes.
    Something like this

    JSON.stringify({
      template: { content: ... },
      data: { .... }
    }).length*4
    

    Note you can increase the input request limit if you want to.



  • Awesome, thanks @jan_blaha
    Right now I've also did the same i.e. increased the input request limit and it started working fine. :)


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.