How to calculate crc16 from Json buffer

Your crc function has a couple of problems.
First, buf(length) should be buf[length].
Second, and even more important, although the function uses the CRC16 polynomial (same as used in XMODEM), you are calculating it from the end of the buffer backwards. You must calculate it in the order that it is transmitted which is from the first char to the last (unless the other end also calculates the CRC "backwards" - see below (*)). Your code should be this:

uint16_t test_crc16(char* buf, int len) {
  unsigned char x;
  unsigned short crc = 0xFFFF;

  for(int i = 0; i < len;i++) {
    x = (crc >> 8) ^ buf[i];
    x ^= x >> 4;
    crc = (crc << 8) ^ ((unsigned short)(x << 12)) ^ ((unsigned short)(x << 5)) ^ ((unsigned short)x);
  }
  return crc;
}

Pete
(*) I see that you are storing it in EEPROM in which case if you encode and decode the CRC with the same function, it won't really matter.