Extract nested attribute value from JSON String using Apex

Salesforce offers two main ways to extract values from a JSON string
1) JSON.deserialize() This approach requires you to have a wrapper class/other valid entity to deserialize the data to.
2) JSON.createParser(jsonString) This approach requires you to loop through a bunch of confusing parser.nextToken() calls

In this article I am introducing an easy to use utility to extract inner attribute values from any JSON string. This is leveraging JSON.createParser(). But once you have this utility, you don't have to go through the parser.nextToken() confusion.

Example of use
Utils.extractAttributeFromJson('{"data":{"user":{"organization":{"id":"123"}}}}', 'data.user.organization.id');


Please note that it will be more performant to use JSON.createParser() directly if you have multiple attributes to extract from the JSON.