承接 cryde/json-text-extractor 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cryde/json-text-extractor

最新稳定版本:0.0.3

Composer 安装命令:

composer require cryde/json-text-extractor

包简介

Helper that will extract JSON from plain text

README 文档

README

Small library that will help extract JSON from plain text

Installation

composer require cryde/json-text-extractor

Usage

The usage is pretty straightforward.

use Cryde\JsonTxtExtractor\JsonTextExtractor;

$str = <<<STR
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla elit lectus, volutpat eget turpis id, bibendum convallis erat. Ut posuere sapien felis, at ornare elit vulputate ut. 
Vestibulum egestas, diam suscipit mattis bibendum, nisi arcu ullamcorper justo.

{
  "id": "0001",
  "type": "donut",
  "name": "Cake",
  "topping": [
    {
      "id": "5001",
      "type": "None"
    },
    {
      "id": "5002",
      "type": "Glazed"
    }
  ]
}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla elit lectus, volutpat eget turpis id, bibendum convallis erat. Ut posuere sapien felis, at ornare elit vulputate ut. 
Vestibulum egestas, diam suscipit mattis bibendum, nisi arcu ullamcorper justo.

{"key": "value"}
Vestibulum egestas, diam suscipit mattis bibendum, nisi arcu ullamcorper justo.
STR;


$textJsonExtractor = new JsonTextExtractor();

var_dump($textJsonExtractor->getJsonStrings($str));
/*
array(2) {
  [0] =>
  string(184) "{
  "id": "0001",
  "type": "donut",
  "name": "Cake",
  "topping": [
    {
      "id": "5001",
      "type": "None"
    },
    {
      "id": "5002",
      "type": "Glazed"
    }
  ]
}"
  [1] =>
  string(16) "{"key": "value"}"
}

*/

Use cases

  • extract JSON from strings returned by ChatGPT : sometimes (even though you explicit asked to not do that) it will add some explanations around the JSON returned
  • tell me if you have other use cases

Feedback / Bugs

If you have any feedback, please open an issue.
I may not have covered all cases. If you have one not covered add it to your issue.
Do not hesitate to open an issue if you have an idea to improve this small library.

统计信息

  • 总下载量: 8.4k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固