In OJS 2.3 there was a JSON class bundled with lib/pkp.  In 2.4, that class was moved to lib/pkp/lib/json and can be accessed using the JSONManager class in lib/pkp/classes/core instead, by calling that JSONManager::encode()