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,865 This week: 326Up
Version License PHP version Categories
json-key-ignorer 1.0.0Freely Distributable5PHP 5, Data types, Parsers
Description 

Author

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: 396634 in Philippines Philippines
Week rank: 312 Up2 in Philippines Philippines Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php
require_once('ignore.php');
$ignore = new Ignore;

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

$exclude = "api_key, email, username";

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


?>


Details

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 README.md Doc. documentation

 Version Control Unique User Downloads Download Rankings  
 0%
Total:253
This week:0
All time:7,865
This week:326Up
 User Ratings  
 
 All time
Utility:65%StarStarStarStar
Consistency:60%StarStarStarStar
Documentation:70%StarStarStarStar
Examples:70%StarStarStarStar
Tests:-
Videos:-
Overall:52%StarStarStar
Rank:2293