我如何解析此json数据? [英] How can i parse this json data?

查看:113
本文介绍了我如何解析此json数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个json编码值

I have this json encoded values

"AllEvents":[
         {
            "eventId":"22",
            "eventTitle":"VANGUARD Friday w/ Colette - Free All Night w/ RSVP!",
            "eventImageUrl":"events/64ffcc09e1c3e73a17c998035ecd7f72.jpeg",
            "eventDescription":"Pete G presents     Friday, September 24, 2010 @ VANGUARD Hollywood    OM Records & Candy Talk welcomes ..    Main Room:  .COLETTE (Los Angeles) OM Records, Candy Talk  .CHUCK LOVE (Minneapolis) Love Network Tour, Om Records  .ANDY COMPTON (UK) The Rurals, Kholofelo Lp Tour    Patio Hosted by Droid Behavior:  .RAíZ aka ACID CIRCUS (Los Angeles) Droid Behavior  .DEAN PAUL vs VIK CARRILLO (Los Angeles) Droid Behavior  .DJ MODESTY (Los Angeles) Friendly Integration    21+ to Enter | Doors Open 10pm-3am+  Free Entry All Night Long w/ RSVP  __________________________________    + PLAYHOUSE Mondays | ECCO Wednesdays | MY HOUSE Fridays | VANGUARD Fridays | MUSIC BOX Saturdays +  __________________________________    To RSVP Please  1.) E-Mail Pete@SuperstarsVIP.com  2.) Text 323.394.3917 (Pete G)  3.) Sign Up Online @ http://www.SuperstarsVIP.com"
         },{
            "eventId":"30",
            "eventTitle":"test title",
            "eventImageUrl":"events/eb5afdce0e8e687b21112162733df5ba.jpeg",
            "eventDescription":"zxzxzx"
         },{
            "eventId":"80",
            "eventTitle":"OH YOU FANCY FRIDAYS @ Push Lounge",
            "eventImageUrl":"events/6eda786bdd8d07d93e300305df66cac4.jpeg",
            "eventDescription":"Skum Entertainment presents...<br />
OH YOU FANCY FRIDAYS<br />
Every other Friday "Oh You Fancy! Friday's" at Push Loungee<br />
...2 for 1 drinks from 9pm-12am!<br />
$5 cover - Admission includes a drink ticket!<br />
21+ only - Bring your ID!<br />
<br />

This week! Friday, February 11th<br />
- DJ G-Rock spinning your favorites in Hip Hop, Top 40 & Rap<br />
- Live performance by T-KO (www.myspace.com/terrakilla)<br />
- Roaming photography by OHDAGYO & SKUM<br />
- Wings World Food Truck out front!<br />
- Special birthday celebration for your favorite bartender Jesse Diaz!<br />
<br />
PUSH LOUNGE<br />

20969 Ventura Blvd<br />
Woodland Hills, CA 91364<br />
(Entrance is on Peralta St)<br />
Parking is FREE!"
         },{
            "eventId":"21",
            "eventTitle":"Benny Benassi - Limited $25 Tickets!",
            "eventImageUrl":"events/2f64e7a15388364d0a9059f42725df77.jpeg",
            "eventDescription":"Decor presents BENNY BENASSI this Saturday @ The Music Box 10pm-4am!<br />
<br />
Insomniac and The Box will collaborate to bring the electronic music scene to vivid life Saturday nights at the legendary Music Box Theatre. <br />
<br />
Experience our mega sound system, world class artists, sexy dancefloor, CO2 cannons, Rooftop patio, gigantic LED visual display at Hollywood's biggest 21+ party!<br />
<br />
"Benny Benassi (born Marco Benassi; July 13, 1967) is a Grammy Award winning Italian DJ and producer of electro house music. He is best known for his 2002 summer club hit "Satisfaction". Benny Benassi ranks as the 10th most popular DJ in the world according to The DJ List website. On October 28, 2009, DJ Magazine announced the results of their annual Top 100 DJ Poll, with Ultra Records artist Benny Benassi placed #26, 13 spots higher than the previous year."<br />

<br />
http://en.wikipedia.org/wiki/Benny_Benassi<br />
<br />
Pre-Sales Highly Encouraged!! Get them NOW before ticket prices increase. If you don't have a pre-sale ticket you will probably not get in. This event is likely to sell out in advance.  If it doesn't tickets at the door are going to cost an arm and a leg and you're going to have to either wait in line for hours or arrive by 9pm.  Please be forewarned! ;)<br />
<br />
$25 tickets online for a limited time @<br />
http://tinyurl.com/benny-benassi-at-the-box"
         }

但是当我在 http://jsonformatter.curiousconcept.com/#jsonformatter 中运行它时,它给出错误

but when i run it in http://jsonformatter.curiousconcept.com/#jsonformatter it gives errors

我已经将此变量应用到可以给我描述的变量上.

i have applied this to variable which gives me description.

$AllEvent[$i]['even_desc'] = str_replace(array("\r\n", "\r", "\n","<br />"), " ", $AllEvent[$i]['even_desc']);

请帮助.

推荐答案

看看我的此外,您还必须在JSON中转义"(如果使用突出显示语法的方式查看问题代码,则会看到蓝色部分,这是"的转义未命中的地方:

Also you have to escape " in JSON (If you look at the code of your question with syntax highlighting you'll see some part in blue, this is where the escaping of the " misses:

Every other Friday "Oh You Fancy! Friday's" at Push Loungee<br />

应变成:

Every other Friday \"Oh You Fancy! Friday's\" at Push Loungee<br />

请注意\"而不是".

这篇关于我如何解析此json数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆