 //Sends all calibrated receiver input max and min values as JSON over the serial interface
 void sendCalibrationJsonData() {
   StaticJsonBuffer<CHAR_ARRAY_SIZE> jsonBuffer;
-  JsonObject& root = jsonBuffer.createObject();
-  JsonObject &calibrationData = jsonBuffer.createObject();;
-  calibrationData["aileronMin"] = aileronMin;
-  calibrationData["aileronMax"] = aileronMax;
-  calibrationData["elevatorMin"] = elevatorMin;
-  calibrationData["elevatorMax"] = elevatorMax;
-  calibrationData["rudderMin"] = rudderMin;
-  calibrationData["rudderMax"] = rudderMax;
-  calibrationData["throttleMin"] = throttleMin;
-  calibrationData["throttleMax"] = throttleMax;
-  calibrationData["cutoverMin"] = cutoverMin;
-  calibrationData["cutoverMax"] = cutoverMax;
-  root["calibrationData"] = calibrationData;
+  JsonObject &root = jsonBuffer.createObject();
+  JsonObject &calibration = jsonBuffer.createObject();;
+  calibration["aileronInMin"] = aileronInMin;
+  calibration["aileronInMax"] = aileronInMax;
+  calibration["elevatorInMin"] = elevatorInMin;
+  calibration["elevatorInMax"] = elevatorInMax;
+  calibration["rudderInMin"] = rudderInMin;
+  calibration["rudderInMax"] = rudderInMax;
+  calibration["throttleInMin"] = throttleInMin;
+  calibration["throttleInMax"] = throttleInMax;
+  calibration["cutoverInMin"] = cutoverInMin;
+  calibration["cutoverInMax"] = cutoverInMax;
+  root["calibration"] = calibration;
   Serial.print(startMarker);
   root.printTo(Serial);
   Serial.println(endMarker);

  //If the cutover switch is flipped, set manualControl accordingly
  if (servoInputFlagsLocal & FLAG_CUTOVER) {
    //Only use cutover values within the set range for receiver input
    if (isValidReceiverInput(cutoverInValueLocal)) {
      if (calibrationMode) {
        if (cutoverInValueLocal > cutoverMax) cutoverMax = cutoverInValueLocal;
        if (cutoverInValueLocal < cutoverMin) cutoverMin = cutoverInValueLocal;
      } else if (isCalibrated) {
        if (manualControl && cutoverInValueLocal > (cutoverMax - CUTOVER_BUFFER)) {
          manualControl = false;
          sendJson("manualControl", manualControl);
        } else if (!manualControl && cutoverInValueLocal < (cutoverMin + CUTOVER_BUFFER)) {
          manualControl = true;
          sendJson("manualControl", manualControl);
        }
      }
    } else {
      sendJson("error", "Cutover input value out of range");
    }
  }
  //Process input for each servo that received new input from the receiver
  if (servoInputFlagsLocal & FLAG_AILERON) {
    //Only use aileron values within the set range for receiver input
    if (isValidReceiverInput(aileronInValueLocal)) {
      if (calibrationMode) {
        if (aileronInValueLocal > aileronMax) aileronMax = aileronInValueLocal;
        if (aileronInValueLocal < aileronMin) aileronMin = aileronInValueLocal;
      } else if (manualControl) {
        processServoInput(aileron, aileronInValueLocal, "aileron", "Unassigned aileron pin");
      }
    } else {
      sendJson("error", "Aileron input value out of range");
    }
  }
  if (servoInputFlagsLocal & FLAG_ELEVATOR) {
    //Only use elevator values within the set range for receiver input
    if (isValidReceiverInput(elevatorInValueLocal)) {
      if (calibrationMode) {
        if (elevatorInValueLocal > elevatorMax) elevatorMax = elevatorInValueLocal;
        if (elevatorInValueLocal < elevatorMin) elevatorMin = elevatorInValueLocal;
      } else if (manualControl) {
        processServoInput(elevator, elevatorInValueLocal, "elevator", "Unassigned elevator pin");
      }
    } else {
      sendJson("error", "Elevator input value out of range");
    }
  }
  if (servoInputFlagsLocal & FLAG_RUDDER) {
  //Only use rudder values within the set range for receiver input
    if (isValidReceiverInput(rudderInValueLocal)) {
      if (calibrationMode) {
        if (rudderInValueLocal > rudderMax) rudderMax = rudderInValueLocal;
        if (rudderInValueLocal < rudderMin) rudderMin = rudderInValueLocal;
      } else if (manualControl) {
        processServoInput(rudder, rudderInValueLocal, "rudder", "Unassigned rudder pin");
      }
    } else {
      sendJson("error", "Rudder input value out of range");
    }
  }
  if (servoInputFlagsLocal & FLAG_THROTTLE) {
    //Only use throttle values within the set range for receiver input
    if (isValidReceiverInput(throttleInValueLocal)) {
      if (calibrationMode) {
        if (throttleInValueLocal > throttleMax) throttleMax = throttleInValueLocal;
        if (throttleInValueLocal < throttleMin) throttleMin = throttleInValueLocal;
      } else if (manualControl) {
        processServoInput(throttle, throttleInValueLocal, "throttle", "Unassigned throttle pin");
      }
    } else {
      sendJson("error", "Throttle input value out of range");
    }
  }
}

}

//Example JSON strings below:
//@{"config":{"throttle":10, "elevator":9, "rudder":8, "aileron":7, "aileronIn":6, "throttleIn":5, "elevatorIn":4, "rudderIn":3, "cutoverIn":2}, "servos":{"throttle":32, "elevator":90, "rudder":90, "aileron":90}}#
//@{"calibration":{"aileronInMin":1084,"aileronInMax":1688,"elevatorInMin":964,"elevatorInMax":1752,"rudderInMin":1044,"rudderInMax":1800,"throttleInMin":1020,"throttleInMax":1704,"cutoverInMin":776,"cutoverInMax":1844}}#
//@{"ranges":{"aileronMin":45, "aileronMax":135, "elevatorMin":0, "elevatorMax":180, "rudderMin":0, "rudderMax":180, "throttleMin":32, "throttleMax":124}}#
//@{"servos":{"throttle":0, "elevator":100, "aileron":120, "rudder":75}}#
void processReceivedJson() {
  if (newData) {
    StaticJsonBuffer<CHAR_ARRAY_SIZE> jsonBuffer;
