Need help sending json array with esp8266

im trying to send a json array to the client but the server is just sending a number “204” instead of an actual array.

void handlegetjson() {
  StaticJsonDocument<500> doc;
  JsonArray analogValues = doc.createNestedArray("analog");
  JsonArray digitalValues = doc.createNestedArray("digital");

  for (int pin = 0; pin < 6; pin++) {
    int value = analogRead(A0);
    // Add the value at the end of the array

  for (int pin = 0; pin < 14; pin++) {
    int value = analogRead(A0);
    // Add the value at the end of the array
  String JSON = String(measureJsonPretty(doc));
  server.send(200, "text/plane", JSON);

The serial.print is also printing the same number that the web client is receiving. how do i send the array?

I think what i'm seeing is the size of the object. how do i send doc as an array?

measureJsonPretty apparently returns a size as you observe. Perhaps you need serializeJson instead.

This is what i needed,

 String JSON;
  serializeJson(doc, JSON);
  server.send(200, "text/plane", JSON);

i went ahead and went with the JSON Object instead of array.

Then i was able to access it in JS like this,

    function getData() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
    var tm1object = JSON.parse(this.responseText);
    document.getElementById("tm1t1ont").innerHTML = tm1object.tm1t1ont;
    document.getElementById("tm1t1offt").innerHTML = tm1object.tm1t1offt;
};"GET", "gettm1json", true);