把json数据 [ { } ] 转为数组

$str = [{"rwx_price":388.5,"end_station_name":"长沙","swz_price":0,"swz_num":"--","to_station_name":"长沙","ydz_num":"--","yz_num":"*","rw_num":"*","arrive_days":"1","rz_num":"--","access_byidcard":"0","yz_price":138.5,"ywz_price":246.5,"sale_date_time":"1100","from_station_code":"CUW","rz_price":0,"gjrw_num":"--","to_station_code":"CSQ","ydz_price":0,"wz_price":138.5,"tdz_price":0,"run_time":"15:36","yw_num":"*","edz_price":0,"qtxb_price":0,"can_buy_now":"N","yw_price":238.5,"train_type":"K","rw_price":372.5,"note":"7月22日11点起售","train_no":"760000K5780K","train_code":"K579","from_station_name":"重庆北","run_time_minute":"936","ywx_price":255.5,"arrive_time":"05:28","start_station_name":"成都东","start_time":"13:52","wz_num":"*","edz_num":"--","qtxb_num":"--","train_start_date":"20160919","gjrw_price":0,"tdz_num":"--"},{"rwx_price":0,"end_station_name":"长沙","swz_price":0,"swz_num":"--","to_station_name":"长沙","ydz_num":"--","yz_num":"*","rw_num":"--","arrive_days":"1","rz_num":"--","access_byidcard":"0","yz_price":128.5,"ywz_price":230.5,"sale_date_time":"1100","from_station_code":"CUW","rz_price":0,"gjrw_num":"--","to_station_code":"CSQ","ydz_price":0,"wz_price":128.5,"tdz_price":0,"run_time":"14:10","yw_num":"*","edz_price":0,"qtxb_price":0,"can_buy_now":"N","yw_price":222.5,"train_type":"K","rw_price":0,"note":"7月22日11点起售","train_no":"760000K50406","train_code":"K504","from_station_name":"重庆北","run_time_minute":"850","ywx_price":237.5,"arrive_time":"06:22","start_station_name":"成都东","start_time":"16:12","wz_num":"*","edz_num":"--","qtxb_num":"--","train_start_date":"20160919","gjrw_price":0,"tdz_num":"--"},{"rwx_price":509.5,"end_station_name":"广州","swz_price":0,"swz_num":"--","to_station_name":"长沙","ydz_num":"--","yz_num":"*","rw_num":"*","arrive_days":"1","rz_num":"--","access_byidcard":"0","yz_price":180.5,"ywz_price":321.5,"sale_date_time":"1100","from_station_code":"CUW","rz_price":0,"gjrw_num":"--","to_station_code":"CSQ","ydz_price":0,"wz_price":180.5,"tdz_price":0,"run_time":"20:47","yw_num":"*","edz_price":0,"qtxb_price":0,"can_buy_now":"N","yw_price":310.5,"train_type":"K","rw_price":488.5,"note":"7月22日11点起售","train_no":"770000K35804","train_code":"K358","from_station_name":"重庆北","run_time_minute":"1247","ywx_price":331.5,"arrive_time":"20:07","start_station_name":"重庆北","start_time":"23:20","wz_num":"*","edz_num":"--","qtxb_num":"--","train_start_date":"20160919","gjrw_price":0,"tdz_num":"--" }]‘;$str = json_decode($str,true);

echo ‘<meta http-equiv="Content-type" content="text/html:charset=utf-8">‘;echo ‘<pre>‘;var_dump($str);exit;
时间: 2024-10-17 03:29:03

把json数据 [ { } ] 转为数组的相关文章

mustache 获取json数据内数组对象指定元素的方法

由于最近项目再用mustache,因此发现了这个问题,mustache无法获取json数据内数组键值的指定索引的元素 遂上网查资料总结一下两种方法 1,数据为数组对像 var obj = [{name: 'foo'}, {name: 'bar'}]; var tmp = '{{#1}}{{name}}{{/1}}'; console.log(Mustache.render(tmp, obj)); //bar 这种方法个人觉得有一定局限性 -----参照:http://stackoverflow.

php json字符串转为数组或对象

从网上查到的方法是 用get_object_vars 把类类型转换成数组 然后在用foreach  遍历即可 $array = get_object_vars($test); $json= '[{"id":"1","name":"\u5f20\u96ea\u6885","age":"27","subject":"\u8ba1\u7b97\u673a\u79d

json_decode转换json数据为数组出现的问题!

json_decode这个函数是json_encode的反函数,一般传递数据的时候为了压缩数据,会将数组格式的数据转换成json格式,用到的函数就是json_encode,然后接收到数据之后再用json_decode转换回数组,这里本来应该不会出现什么问题, 但也有意外,这个意外应该可以说也是自己造成,bom头导致的bug,其实准确来说也不算bug,但就是让你的数据无法正确转换回来: bom头的产生应该是你的文件在windows下用记事本这些东西编辑过之后的后果,可能无意之间就给这个bug的产生

JAVA解析JSON数据

转自:http://www.cnblogs.com/boy1025/p/4551593.html 3.解析JSON数据(小编使用的GSON进行json数据的解析) 3-1 [JSONObject的解析] 下面是一个json文件: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

Ajax请求返回Json数据

介绍一下用Ajax向服务器请求数据的方法,以及对于返回的Json数据的使用. 1 $.ajax({ 2 type:"post", 3 async:false, 4 url: ******** 5 data:{"province":$("#provice").val(), 6 "city":$("#city").val(), 7 "area":$("#area").va

导出excel时,以form方式提交json数据

今天在写项目时写到一个excel的导出,开始想用ajax请求后台后导出,但发现ajax会有返回值,而且ajax无法直接输出文件,而后台的excel导出方法已经封装好,不方便修改. 就改用了提交的方式form,但form提交,表格分页用的是jquerytable,我需要将一些jquerytable的一些参数传到后台,但这些数据已经是json数据,如果我直接放在input中提交到后台在解析参数会很麻烦,所以就想将json数据转为form方式提交. js //导出 function exportExc

让复杂Json数据和对象自由转换 --- Gson

Gson是谷歌用于对Json操作的库,里面有着强大而又方便的功能,最常用的就是 fromJson():将json数据转化为对象: toJson():将对象转化为json数据! 对于普通的json数据使用这两个方法简直so easy,但是对于稍有点复杂的json数据如何操作呢? 比如json数据中除了json对象外,还有json数组, 有点抽象,来个例子: 比如想通过对象生成一下json数据: 1 { 2 "age": "21", 3 "mList"

安卓中解析json数据

一.概述 JSON是JavaScript Object Notation的简称,起源于js(javascript)它是一种轻量级的数据交换格式,JSON不仅在js中广泛使用,同时还在其他领域得到广泛使用,如c,c++,java,Php,swift等等,成为了一种通用的理想数据交换格式,它有两种数据结构,分别是对象,数组,它形式上有花括号{}和中括号[]嵌套,{}中的是代表对象,[]中的为数组,即对象中有数组,数组中又有对象,而且以及键/值对出现. json语法: 数据在键值对中 数据有逗号分离

将Json数据转换为ADO.NET DataSet对象

Json数据转换为ADO.NET DataSet其实方法有很多,Newtonsoft.Json也提供了DataSet的Converter用以转换Json数据.但是有些情况下DataSet Converter并不管用,而且也不一定能够满足项目需要.这里介绍另一种简单有效的方法,能够方便快速地将Json数据转为ADO.NET DataSet. 设计 事实上Newtonsoft.Json已经提供了一套完整的Json数据文档结构,Newtonsoft.Json.Linq命名空间下提供了这种文档结构的对象