惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Threat Research - Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
A
Arctic Wolf
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
I
Intezer
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
Latest news
Latest news
Help Net Security
Help Net Security
S
Security Affairs
Webroot Blog
Webroot Blog
The Hacker News
The Hacker News
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tor Project blog
Forbes - Security
Forbes - Security
Google DeepMind News
Google DeepMind News
AWS News Blog
AWS News Blog
Attack and Defense Labs
Attack and Defense Labs
P
Proofpoint News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Help Net Security
L
Lohrmann on Cybersecurity
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
MongoDB | Blog
MongoDB | Blog
Cyberwarzone
Cyberwarzone
The Last Watchdog
The Last Watchdog
S
Securelist
N
News and Events Feed by Topic
S
Secure Thoughts
F
Fortinet All Blogs
博客园_首页
C
Cybersecurity and Infrastructure Security Agency CISA
量子位
M
MIT News - Artificial intelligence
F
Full Disclosure
T
The Blog of Author Tim Ferriss
T
Tailwind CSS Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
P
Privacy International News Feed
L
LangChain Blog
Know Your Adversary
Know Your Adversary
C
CERT Recently Published Vulnerability Notes

立云图志 - 索引

44,夏至 44,芒种 L.Plog.v1 超出预期的浏览体验 44,小满 个性化图志系统 44,立夏 44,谷雨 44,清明 44,春分 被嫌弃的博客图像处理 44,惊蛰 44,雨水 90% 44,立春 44,大寒 只想好好听首歌 44,小寒 44,冬至 写而为己 44,大雪 对友链的思考 44,小雪 44,立冬 44,霜降 有声:东风坝开合浮桥 44,寒露 戒烟已十年 C/2025 A6 Lemmon 44,秋分 Typecho 相册主题 Snapic Plus v6 寻求贡献者 44,白露 43,处暑 43,立秋 Typecho 图志主题:Snapic Paper 43,大暑 43,小暑 43,夏至 预料中的又倒下一批 Typecho 主题、模板、插件 给 Typecho 博客添加申请友链、站点收藏等功能 43,芒种 给 Typecho 博客添加旅行足迹地图标记功能 43,小满 给 Typecho 博客添加评论者「都说了啥」功能 43,立夏 43,谷雨 43,清明 43,春分 Typecho 记事阅读主题:Snapic Just 640px 43,惊蛰 43,雨水 43,立春 43,大寒 43,小寒
与 Typecho 相关
作者: Lopwon · 2025-10-11 · via 立云图志 - 索引

· Picture by ChatGPT· Picture by ChatGPT

在重制 Snapic Plus 过程中,需要把 JSON 字符串转换为数组,于是构建了以下函数:


    function jsonStringToArray($jsonString, $associative = true)
    {

        if (!is_string($jsonString) || empty(trim($jsonString))) {
            return $associative ? [] : null;
        }

        $decodedData = @json_decode($jsonString, $associative);

        if (json_last_error() === JSON_ERROR_NONE) {
            return $decodedData;
        }

        return $associative ? [] : null;

    }

    $data = '{"last_update_timestamp":"1760160739","total_media_count":576}';

    jsonStringToArray($data); // 转为数组
    jsonStringToArray($data, false); // 转为对象

事后细想,这是常用的功能,Typecho 或许有内置的,果然,在 var/Typecho/Common.php 文件里找到了:


    $data = '{"last_update_timestamp":"1760160739","total_media_count":576}';

    Json::decode($data); // 转为对象
    Json::decode($data, true); // 转为数组

这样的现象还挺普遍,由于官方提供的使用文档略显粗犷,主题、插件的开发者们常常会忽略这些自带的方法、组件等,这么一来,无形中增加了制作的时间开销,也存在升级新版 Typecho 时,主题、插件代码失效报错的情况,比如(这里)提及的偏方。

此外,不少主题会使用诸如以下的标记方式对文章内容进行替换,以输出自定义的丰富版式,但是,由于官方似乎没有制定统一的开发规范,导致不同开发者使用了不同风格去实现相似的渲染结果,致使在切换主题时,无法正确兼容适配。


    [photos][/photos] // 开发者 A
    [fotos][/fotos] // 开发者 B

26 视频:中缅边境,填坑行

尼康D90相机抓拍进藏骑行者

1374141600

尼康D90相机抓拍进藏骑行者

明天的天气不会太糟,可以出发

1348999200

明天的天气不会太糟,可以出发