# Json buffer size

**URL:** <https://wled.discourse.group/t/json-buffer-size/5095>\
**Category:** Questions\
**Created:** [March 22, 2022, 10:02am UTC](https://wled.discourse.group/t/json-buffer-size/5095 "2022-03-22T10:02:07Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![DhairyaSharma7120](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/dhairyasharma7120/32/2993_2.png) [@DhairyaSharma7120](https://wled.discourse.group/u/DhairyaSharma7120)\
**Post date:** [March 22, 2022, 10:02am UTC](https://wled.discourse.group/t/json-buffer-size/5095/1 "2022-03-22T10:02:07Z")

</div>

I am using json api to set the color of individual led  
for example:  
`{“seg”:{“i”:[0,[255,0,0],1,[0,128,0],2,[0,0,255]]}}`  
So in my case i have 1200 leds and this i array is of length 2400 i am getting error 9 in response  
or some time bad request.

So how to configure the json configuration for this to work , i am using esp32 4mb

---

<div class="post-metadata">

**Author:** ![ALDIY](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/aldiy/32/2716_2.png) [@ALDIY](https://wled.discourse.group/u/ALDIY)\
**Post date:** [March 22, 2022, 11:51am UTC](https://wled.discourse.group/t/json-buffer-size/5095/2 "2022-03-22T11:51:03Z")

</div>

The command below referenced in the kno.wled.ge works fine under mac but gives error 9 under windows

curl -X POST “http://[WLED-IP]/json/state” -d ‘{“on”:“t”,“v”:true}’ -H “Content-Type: application/json”

I have also seen others talk about error 9 under windows  
The correct command under windows is listed below :

 ![json](https://global.discourse-cdn.com/free1/uploads/wled/original/2X/0/0441ce1564d09652cdf8e1555a8f6b90458737b0.jpeg)

or complete one  
curl [http://wled-ip/json](http://wled-ip/json) -d {\“on\”:\“t\”,\“v\”:true} -H “Content-Type: application/json”

---

<div class="post-metadata">

**Author:** ![ALDIY](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/aldiy/32/2716_2.png) [@ALDIY](https://wled.discourse.group/u/ALDIY)\
**Post date:** [March 22, 2022, 1:58pm UTC](https://wled.discourse.group/t/json-buffer-size/5095/3 "2022-03-22T13:58:45Z")

</div>

For your command try this :

curl [http://wled-ip/json](http://wled-ip/json) -d {\“seg\”:{\“i\”:[0,[255,0,0],1,[0,128,0],2,[0,0,255]]}} -H “Content-Type: application/json”

---

<div class="post-metadata">

**Author:** ![Artacus](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/artacus/32/1258_2.png) [@Artacus](https://wled.discourse.group/u/Artacus)\
**Post date:** [March 22, 2022, 8:27pm UTC](https://wled.discourse.group/t/json-buffer-size/5095/4 "2022-03-22T20:27:17Z")

</div>

That is a lot of LED data to be transferring in a non-binary format. You should look into using something like DMX.

---

<div class="post-metadata">

**Author:** ![blazoncek](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/blazoncek/32/1886_2.png) [@blazoncek](https://wled.discourse.group/u/blazoncek)\
**Post date:** [March 22, 2022, 9:28pm UTC](https://wled.discourse.group/t/json-buffer-size/5095/5 "2022-03-22T21:28:25Z")

</div>

As @Artacus said, this is too many LEDs for ArduinoJson to handle in memory.  
Arrays of about 1000 and up single values are known to cause trouble.

---

<div class="post-metadata">

**Author:** ![ALDIY](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/aldiy/32/2716_2.png) [@ALDIY](https://wled.discourse.group/u/ALDIY)\
**Post date:** [March 23, 2022, 2:21am UTC](https://wled.discourse.group/t/json-buffer-size/5095/6 "2022-03-23T02:21:13Z")

</div>

Hello guys ,

Happy to see you are checking this out as it seems a lot of people are interested in individual led control .

Just to clarify your comments does not relate to error 9 but to the led limit that could cause an issue in performance ?

I will create a PR to add your comment for 1000 led limit to the docs below ,which the source of the command example mentioned by the poster , if you have anything to add or rephrase for the same .  
[https://kno.wled.ge/interfaces/json-api/#per-segment-individual-led-control](https://kno.wled.ge/interfaces/json-api/#per-segment-individual-led-control)

Now we got that out of the way , I finally got it to work under windows and was testing with three irregular fixtures ( cubes and rings ) which all under 1000 leds and planning to do heavy scripting on that . Does ledmap help in this case ? Im not really sure if the dmx option only possible with extra hw as there is limited info on the site . Cheers

---

<div class="post-metadata">

**Author:** ![blazoncek](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/blazoncek/32/1886_2.png) [@blazoncek](https://wled.discourse.group/u/blazoncek)\
**Post date:** [March 23, 2022, 3:39pm UTC](https://wled.discourse.group/t/json-buffer-size/5095/7 "2022-03-23T15:39:16Z")

</div>

The limit can be mitigated by custom compiling and increasing JSON buffer size.  
It **will** need thorough testing by the user though.  
There may be other issues so I recommend reading ArduinoJson documentation.

---

<div class="post-metadata">

**Author:** ![DhairyaSharma7120](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/dhairyasharma7120/32/2993_2.png) [@DhairyaSharma7120](https://wled.discourse.group/u/DhairyaSharma7120)\
**Post date:** [March 23, 2022, 3:59pm UTC](https://wled.discourse.group/t/json-buffer-size/5095/8 "2022-03-23T15:59:16Z")

</div>

Yes finding the way to support that heavy data transfer, right now splitting the requests into multiple requests.

---

<div class="post-metadata">

**Author:** ![ALDIY](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/aldiy/32/2716_2.png) [@ALDIY](https://wled.discourse.group/u/ALDIY)\
**Post date:** [March 23, 2022, 8:58pm UTC](https://wled.discourse.group/t/json-buffer-size/5095/9 "2022-03-23T20:58:39Z")

</div>

Could you share the code you used ? when i run something like the below in a nested loop "sometimes it fails " but other times it works or lags a bit .The leds are not more then 256 and mcu(s) are only one meter away from router .

curl [http://10.0.3.61/json](http://10.0.3.61/json) -d {“seg”:{“i”:[%%x,[255,0,0]]}} -H “Content-Type: application/json”

---

<div class="post-metadata">

**Author:** ![DhairyaSharma7120](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/dhairyasharma7120/32/2993_2.png) [@DhairyaSharma7120](https://wled.discourse.group/u/DhairyaSharma7120)\
**Post date:** [March 24, 2022, 5:02am UTC](https://wled.discourse.group/t/json-buffer-size/5095/10 "2022-03-24T05:02:24Z")

</div>

yes 255 is the best i can control even beyond that it crashes

```
let segObj = {
  seg: {
    i: [],
  },
}; //segment object example
```

```
if (segObj?.seg?.i?.length > 200) {
      let newSegObj = JSON.parse(JSON.stringify(segObj));
        let array = segObj?.seg?.i;
        let result = [];
        let valuesCount = 0;
        while (valuesCount < segObj?.seg?.i?.length) {
          result.push(array.slice(valuesCount, valuesCount + 200));
          valuesCount += 200;
        }
        result?.forEach((ele) => {
          newSegObj.seg.i = ele;
          requestJson(newSegObj); //
        });
        return;
 }
```

this is how i splitting request if and sending data for 100 leds in one request

---

<div class="post-metadata">

**Author:** ![blazoncek](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/blazoncek/32/1886_2.png) [@blazoncek](https://wled.discourse.group/u/blazoncek)\
**Post date:** [March 24, 2022, 8:46am UTC](https://wled.discourse.group/t/json-buffer-size/5095/11 "2022-03-24T08:46:19Z")

</div>

add some time slack in your requests or not all may get processed.  
too fast and they may even cause ESP to reboot

---

<div class="post-metadata">

**Author:** ![DhairyaSharma7120](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/dhairyasharma7120/32/2993_2.png) [@DhairyaSharma7120](https://wled.discourse.group/u/DhairyaSharma7120)\
**Post date:** [March 24, 2022, 8:55am UTC](https://wled.discourse.group/t/json-buffer-size/5095/12 "2022-03-24T08:55:54Z")

</div>

yes will put some time interval between each request. it will work while setting the individual leds, but wont work while saving it as a preset.

---

<div class="post-metadata">

**Author:** ![ALDIY](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/aldiy/32/2716_2.png) [@ALDIY](https://wled.discourse.group/u/ALDIY)\
**Post date:** [March 25, 2022, 12:16am UTC](https://wled.discourse.group/t/json-buffer-size/5095/13 "2022-03-25T00:16:38Z")

</div>

Is there any another way to control the individual leds without having a delay ?Or I just use other software to do that

---

<div class="post-metadata">

**Author:** ![blazoncek](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/blazoncek/32/1886_2.png) [@blazoncek](https://wled.discourse.group/u/blazoncek)\
**Post date:** [March 25, 2022, 6:36am UTC](https://wled.discourse.group/t/json-buffer-size/5095/14 "2022-03-25T06:36:38Z")

</div>

UDP realtime/Hyperion, DDP, E1.31, ArtNet

---

<div class="post-metadata">

**Author:** ![ALDIY](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/aldiy/32/2716_2.png) [@ALDIY](https://wled.discourse.group/u/ALDIY)\
**Post date:** [March 26, 2022, 3:15am UTC](https://wled.discourse.group/t/json-buffer-size/5095/15 "2022-03-26T03:15:20Z")

</div>

Yes I have been testing different protocols ,my mac does not like Hyperion but this seems really interesting , i just tested it today for first time , including individual led control [GitHub - psieg/Lightpack: Lightpack and Prismatik open repository](https://github.com/psieg/Lightpack)
