JSON PHP中 数组/对象转成JSON字符串
json
适用于现代 C++ 的 JSON。
项目地址:https://gitcode.com/gh_mirrors/js/json
免费下载资源
·
<?php
//php语言生成json字符串
//json_encode(数组/对象);
//① 索引数组-->JavaScript数组
$color = array('gold','yellow','blue');
echo json_encode($color)."<br />";// ["gold","yellow","blue"]
//② 关联数组-->json字符串
$city = array('shandong'=>'jinan','henan'=>'zhengzhou','hebei'=>'shijiazhuang');
echo json_encode($city)."<br />";//{"shandong":"jinan","henan":"zhengzhou","hebei":"shijiazhuang"}
//③ 索引关联数组-->json字符串
$city2 = array('shandong'=>'jinan','henan'=>'zhengzhou','shenyang','hebei'=>'shijiazhuang');
echo json_encode($city2)."<br />";//{"shandong":"jinan","henan":"zhengzhou","0":"shenyang","hebei":"shijiazhuang"}
//④ 对象生成json信息-->json字符串
// (只会序列化"成员属性",不会序列化"成员方法")
class Person{
//类内部的成员属性需要有修饰符(var/public/protected/private),其是固定语法
public $color = "yellow";
var $height = 170;
function run(){
echo "is running";
}
}
$tom = new Person();
echo json_encode($tom); //{"color":"yellow","height":170}
GitHub 加速计划 / js / json
18
5
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:3 个月前 )
f06604fc
* :page_facing_up: bump the copyright years
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
* :page_facing_up: bump the copyright years
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
* :page_facing_up: bump the copyright years
Signed-off-by: Niels Lohmann <niels.lohmann@gmail.com>
---------
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Signed-off-by: Niels Lohmann <niels.lohmann@gmail.com> 20 小时前
d23291ba
* add a ci step for Json_Diagnostic_Positions
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* Update ci.cmake to address review comments
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* address review comment
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* fix typo in the comment
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* fix typos in ci.cmake
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* invoke the new ci step from ubuntu.yml
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* issue4561 - use diagnostic positions for exceptions
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* fix ci_test_documentation check
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* address review comments
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* fix ci check failures for unit-diagnostic-postions.cpp
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* improvements based on review comments
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* fix const correctness string
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* further refinements based on reviews
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* add one more test case for full coverage
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* ci check fix - add const
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* add unit tests for json_diagnostic_postions only
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* fix ci_test_diagnostics
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
* fix ci_test_build_documentation check
Signed-off-by: Harinath Nampally <harinath922@gmail.com>
---------
Signed-off-by: Harinath Nampally <harinath922@gmail.com> 1 天前
更多推荐
已为社区贡献4条内容
所有评论(0)