Get string inside void

I’m using JSon to get some values from a database, and I want to use this values, but they’re inside a foreach on a void, how can I get the values ?

Example:

 public void serverResponse(string response)
    {

        JSONObject info = new JSONObject(response);
        Debug.Log(response);
        foreach (JSONObject obj in info.list)
        {
            JSONObject oportunity = obj.GetField("oportunity");
            Debug.Log(oportunity.GetField("id").str);

            foreach (JSONObject h in oportunity.GetField("resources").list)
            {
                string resourceID = h.GetField("resource").str;
                Debug.Log(resourceID);
                string quantity = h.GetField("quantity").str;
                Debug.Log(quantity);
            }
            
        } 

I want to take the quantity string and the resourceID out of the foreach, and I don’t know how to use Getters and Setters. (GET and SET).

I would suggest the out keyword.