+ unwanted_fields = [u"count", u"index", u"context"]
+
+ def process_value(val):
+ """Process value.
+
+ :param val: Value to be processed.
+ :type val: object
+ :returns: Processed value.
+ :rtype: dict or str or int
+ """
+ if isinstance(val, dict):
+ for val_k, val_v in val.items():
+ val[str(val_k)] = process_value(val_v)
+ return val
+ elif isinstance(val, list):
+ for idx, val_l in enumerate(val):
+ val[idx] = process_value(val_l)
+ return val
+ elif isinstance(val, bytes):
+ val.hex()
+ elif hasattr(val, u"__int__"):
+ return int(val)
+ elif hasattr(val, "__str__"):
+ return str(val).encode(encoding=u"utf-8").hex()
+ # Next handles parameters not supporting preferred integer or string
+ # representation to get it logged
+ elif hasattr(val, u"__repr__"):
+ return repr(val)
+ else:
+ return val
+
+ reply_dict = dict()
+ reply_key = repr(api_r).split(u"(")[0]
+ reply_value = dict()
+ for item in dir(api_r):
+ if not item.startswith(u"_") and item not in unwanted_fields:
+ reply_value[item] = process_value(getattr(api_r, item))
+ reply_dict[reply_key] = reply_value
+ return reply_dict
+
+
+def process_json_request(args):
+ """Process the request/reply and dump classes of VPP API methods.
+
+ :param args: Command line arguments passed to VPP PAPI Provider.
+ :type args: ArgumentParser
+ :returns: JSON formatted string.
+ :rtype: str
+ :raises RuntimeError: If PAPI command error occurs.
+ """
+