hasankaya/json-validater
最新稳定版本:v1.0.1
Composer 安装命令:
composer require hasankaya/json-validater
包简介
json validater in php
README 文档
README
- Comparing the length of data in json.
- Comparing types of data in json
- Comparing the number of elements in two different jsons.
- checking for elements inside two different jsons.
Features
- Work continues for the embedded json generation type in the system.
Installation
You can install the latest version of JSON validator with the following command:
composer require hasankaya/json-validater
Documentation
First you have to specify a json format type to use in the comparison.
For Example:
$pageJson = '{
"AppName": "varchar(15)",
"Code": ["varchar(60)","1","4"],
"Adres": ["varchar(30)","0","2"],
"Number": "int"
}
';
The definition of varchar(15) used in the AppName parameter indicates that it will be of type varchar only and up to 15 characters long.
The array created at the Code parameter indicates that there will be a maximum of 60 characters of type varchar(60). The second value in the array means that this field will have to be in the next json. .Also, the fact that the third value in the array is 1 indicates that the value in the next json will be at least 1 character..
For Example:
require_once('xml.class.php');
use Lucky\jsonChecker as jsonChecker;
$jsonController = new jsonChecker;
$input = array("AppName"=>"Test","Code"=>"1234","Adres"=>"111","Number"=>"1234a");
$pageJson = '{
"AppName": "varchar(15)",
"Code": ["varchar(60)","1","4"],
"Adres": ["varchar(30)","1","2"],
"Number": "int"
}
';
$input = $jsonController->checkJsonData($pageJson,json_encode($input));
if(isset($input["Status"]) && $input["Status"] == "false"){
echo json_encode($input);
exit;
}
$input = $jsonController->checkArrayIsset($pageJson,$input);
echo json_encode($input);
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: mit
- 更新时间: 2022-11-22