php 解析文件不知道什么格式
我有一个可以返回温度数据等的硬件。但我不确定这是什么格式。我想用 php 解析它,任何有关解析数据的最佳或最简单方法的建议。我将把数据存储在 mysql 数据库中,并且该数据将每 30 秒插入一个。
以下是数据:
{name:"Enviro",date:"07/22/10 17:32:34",uptime:"0d 19:06:28",scale:0,macaddr:"00: XX:XX:XX:XX:XX",devtype:"24",刷新:"30",传感器:[{label:"机架温度",tempf:"70.88",tempc:"21.60",highf:"72.50 ",highc:"22.50",lowf:"69.98",lowc:"21.10",警报:1,类型:38,启用:1,湿度:"37.27",highh:"45.72",lowh:"34.01", heati:"76.79",heatic:"24.88",highhi:"77.07",highhic:"25.03",lowhi:"76.57",lowhic:"24.76",hienabled:0},{label:"外部传感器 1" ,tempf:"32.00",tempc:"0.00",highf:"32.00",highc:"0.00",lowf:"32.00",lowc:"0.00",警报:0,类型:0,启用:0}, {标签:“暖通空调”,tempf:“46.27”,tempc:“7.93”,highf:“67.87”,highc:“19.93”,lowf:“43.70”,lowc:“6.50”,警报:1,类型:16 ,enabled:1},{label:"外部传感器 3",tempf:"32.00",tempc:"0.00",highf:"32.00",highc:"0.00",lowf:"32.00",lowc:"0.00 ",alarm:0,type:0,enabled:0},{label:"外部传感器 4",tempf:"32.00",tempc:"0.00",highf:"32.00",highc:"0.00",lowf :"32.00",lowc:"0.00",alarm:0,type:0,enabled:0},{label:"外部传感器 5",tempf:"32.00",tempc:"0.00",highf:"32.00 ",highc:"0.00",lowf:"32.00",lowc:"0.00",alarm:0,type:0,enabled:0},{label:"分机。传感器 6",tempf:"32.00",tempc:"0.00",highf:"32.00",highc:"0.00",lowf:"32.00",lowc:"0.00",警报:0,类型:0,启用: 0}],switch_sen:[{label:"气流",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0},{label: " ",启用:1,警报:1,状态:0},{标签:" ",启用:1,警报:1,状态:0},{标签:" ",启用:1,警报:1,状态:0},{标签:" ",启用:1,警报:1,状态:0},{标签:" ",启用:1,警报:1,状态:0},{标签:" ",启用: 1,警报:1,状态:0},{标签:" ",启用:1,警报:1,状态:0},{标签:" ",启用:1,警报:1,状态:0},{标签:" ",启用:1,警报:1,状态:0},{标签:" ",启用:1,警报:1,状态:0},{标签:" ",启用:1,警报:1 ,状态:0},{标签:" ",启用:1,警报:1,状态:0},{标签:" ",启用:1,警报:1,状态:0},{标签:" ",启用:1,警报:1,状态:0}]}
I have an piece of hardware that returns temperature data etc. I am not sure what format this is though. I would like to parse it with php any suggestions on the best or easiest way to parse the data. I will be storing the data in a mysql database and this data will be inserted one every 30 seconds.
Below is the data:
{name:"Enviro",date:"07/22/10 17:32:34",uptime:"0d 19:06:28",scale:0,macaddr:"00:XX:XX:XX:XX:XX",devtype:"24",refresh:"30",sensor:[{label:"Rack Temp",tempf:"70.88",tempc:"21.60",highf:"72.50",highc:"22.50",lowf:"69.98",lowc:"21.10",alarm:1,type:38,enabled:1,humid:"37.27",highh:"45.72",lowh:"34.01",heati:"76.79",heatic:"24.88",highhi:"77.07",highhic:"25.03",lowhi:"76.57",lowhic:"24.76",hienabled:0},{label:"Ext. Sensor 1",tempf:"32.00",tempc:"0.00",highf:"32.00",highc:"0.00",lowf:"32.00",lowc:"0.00",alarm:0,type:0,enabled:0},{label:"HVAC",tempf:"46.27",tempc:"7.93",highf:"67.87",highc:"19.93",lowf:"43.70",lowc:"6.50",alarm:1,type:16,enabled:1},{label:"Ext. Sensor 3",tempf:"32.00",tempc:"0.00",highf:"32.00",highc:"0.00",lowf:"32.00",lowc:"0.00",alarm:0,type:0,enabled:0},{label:"Ext. Sensor 4",tempf:"32.00",tempc:"0.00",highf:"32.00",highc:"0.00",lowf:"32.00",lowc:"0.00",alarm:0,type:0,enabled:0},{label:"Ext. Sensor 5",tempf:"32.00",tempc:"0.00",highf:"32.00",highc:"0.00",lowf:"32.00",lowc:"0.00",alarm:0,type:0,enabled:0},{label:"Ext. Sensor 6",tempf:"32.00",tempc:"0.00",highf:"32.00",highc:"0.00",lowf:"32.00",lowc:"0.00",alarm:0,type:0,enabled:0}],switch_sen:[{label:"Air Flow",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0},{label:" ",enabled:1,alarm:1,status:0}]}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需将其放入数组中即可:
简单/完美/最佳;-)
Simply get it in an array:
Simple/Perfect/Best ;-)
它认为它是 JSON 格式。
It think it is in JSON format.
您可以使用 PEAR 包 - Services_JSON 解析它
You can parse it using PEAR package - Services_JSON