https://hackersandslackers.com/extract-data-from-complex-json-python/-> took the below python code from here
I really need a java code to pull all values of user input specified key from nested json. It takes json as input with key name and returns a list of all values for that particular key in a nested json. i have trouble convering as traversing through json node using java is more complex. Anyone has similar solution ?
def extract_values(obj, key):
    """Pull all values of specified key from nested JSON."""
    arr = []
    def extract(obj, arr, key):
        """Recursively search for values of key in JSON tree."""
        if isinstance(obj, dict):
            for k, v in obj.items():
                if isinstance(v, (dict, list)):
                    extract(v, arr, key)
                elif k == key:
                    arr.append(v)
        elif isinstance(obj, list):
            for item in obj:
                extract(item, arr, key)
        return arr
    results = extract(obj, arr, key)
    return 
