Change this to, as you only need to build the KeyValueSchema once at deserialization time.

    result.remove(idx);
    break;