class_docstr: Implementation. Captures batches in KServe v2 protocol format, returns
  also in FServing v2 protocol format.
class_docstr_tok: ["Implementation",".","Captures","batches","in","KServe","v2","protocol","format",",","returns","also","in","FServing","v2","protocol","format","."]
docstr: Constructs JSON object from data
docstr_tok: ["Constructs","JSON","object","from","data"]
code: def _to_json(self, data, input_name):
      """
      Constructs JSON object from data
      """
      output_data = {}
      data_ndarray = np.array(data).flatten()
      output_data["name"] = input_name
      output_data["datatype"] = _to_datatype(data_ndarray.dtype)
      output_data["data"] = data_ndarray.tolist()
      output_data["shape"] = data_ndarray.flatten().shape
      return output_data
  
file_path: serve/ts/torch_handler/request_envelope/kservev2.py
imports: import json
  import logging
  import numpy
  from .base import BaseEnvelope
label_desc: Use image node_id 6 for calling the KServev2Envelope obj's underlying member method code with example usage: obj._to_json(data, input_name) and returns: output_data