使用php解析类似json的数据
Parsing json like data using php
我有一些类似Json的数据从URL 中抓取
[[["oppl.lr",[,,,,,,,,,,,[[[[[,"A Google User"]
,,,,1]
,3000,,,"Double tree was ok, it wasnt super fancy or anything. Its good for families and just relaxing by the pool. Service was good, and rooms were kept neat.","a year ago",["http://www.ma..",,1],,"","",""]
]
,["Rooms","Service","Location","Value"]
,[]
使用php json_decode()函数无法解析。有没有任何库或其他东西可以让我将其转换为常规json,这样我的任务就会更容易?否则我知道我必须写正则表达式。
提前感谢。
基于您的评论。如果您的数据是
[["oppl.lr",[,,,,,,,,,,,[[,"A Google User"],"",""],""]]]
如果你能以某种方式将数据发送到客户端。那么它就是一个有效的javascript数组。您可以在客户端处理数据,也可以使用
JSON.stringify([["oppl.lr",[,,,,,,,,,,,[[,"A Google User"],"",""],""]]]);
并将数据作为发送回服务器
"[["oppl.lr",[null,null,null,null,null,null,null,null,null,null,null,[[null,"A Google User"],"",""],""]]]"
否则,通过php您可以使用此函数
function getValidArray($input) {
$input = str_replace(",,", ',"",', $input);
$input = str_replace(",,", ',"",', $input);
$input = str_replace("[,", '["",', $input);
return eval("return $input;");
}
您可以根据需要优化上述功能。
相关文章:
- 如何将JSON数据导入我的ejs模板
- 如何将json数据显示为html
- Json数据包含日期和时间格式
- 用我的json数据填充JQuery DataTable
- AngularJS加载JSON数据,然后从中解析/加载HTML
- 使用jquery读取Json数据
- 如何将本地json数据加载到Extjs数据模型中
- 如何使用jquery ajax和jsonp在您自己的域上读取json数据
- React-将jSON数据传递给子组件的子组件
- 尝试从控制器加载带有json数据的Simile时间线
- Jquery:对返回JSON数据的php脚本的Ajax调用
- 如何通过数据分组将json数据转换为嵌套的json数据格式
- 如何在ReactJs中显示Json数据
- 使用javascript进行JSON数据检索
- tu如何将id放在填充了json数据的html表td上
- 将JSON数据从服务器加载到knockout.jsobservable中
- 使用JavaScript处理JSON数据
- 如何将json数据传递到.js文件
- 如何在带有nunjucks和gullow数据的JSON数据中使用带有HTML的内容
- 如何使用var名称调用JSON数据