PHP Classes

PHP Ignore JSON Key: Remove certain key values from JSON strings

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 52%Total: 253 All time: 7,855 This week: 326Up
Version License PHP version Categories
json-key-ignorer 1.0.0Freely Distributable5PHP 5, Data types, Parsers


This class can remove certain key values from JSON strings.

It takes a JSON encoded string and parses it to remove object keys with names passed in an array.

The class returns another JSON string with the specified key removed.

Innovation Award
PHP Programming Innovation award nominee
September 2016
Number 13
JSON is nowadays used by many applications and APIs to exchange data in a format that can be supported by many languages.

Sometimes you need to do some processing to filter unwanted entries in JSON data structure. Usually you would use json_decode parse the data, traverse the parsed data and filter the unwanted information, and regenerate it with json_encode.

This class offers a simpler solution. It can take a JSON string and removed the unwanted entries from the JSON string directly.

This way you do not need to perform traversal of data and custom processing to remove the unwanted data.

Manuel Lemos
Picture of Janjan
  Performance   Level  
Name: Janjan <contact>
Classes: 1 package by
Country: Philippines Philippines
Age: ???
All time rank: 395734 in Philippines Philippines
Week rank: 387 Up7 in Philippines Philippines Up
Innovation award
Innovation award
Nominee: 1x


$ignore = new Ignore;

$val = '{\"message\":\"Password updated successfullyasd\",\"name\":\"Stephen\",\"email\":\"\",\"username\":\"steph5592044d70ff9\",\"status\":\"1\",\"api_key\":\"d738f1c6cc88b8b6d2dcbb9c964b08b2\",\"error\":0,\"message\":\"You are successfully registered\"}';

$exclude = "api_key, email, username";

$ignore->ignore_keys($val, $exclude);



Ignore Key class does something in json you string that you don't need to get them parsed. This is good for api developers if you have raw data and you want to ignore some keys at the same time, not compromising the server's performance since it is using string manipulation to ignore the keys you want.

  Files folder image Files  
File Role Description
Plain text file ignore.php Class ignore class
Accessible without login Plain text file index.php Example index file to access the class
Accessible without login Plain text file Doc. documentation

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:7,855
This week:326Up
 User Ratings  
 All time