javascript - How to Parse Facebook Graph API "hours" response -


I am working with the Facebook Graph API to get some data from the Facebook page but I do not know how the results "Hour" is something like this:

 {"wed_1_open": "17:00", "wed_1_close": "02:00", "thu_1_open": "17:00", "" 02: 00 "," 2_1 "," 1/2 "," 1/2 "", "1/2", "Free_1_close": "02:00", "Sat_1_pennon": "12:00", "sat_1_close": "02:00", "So I wonder how to parse this result to get some human-readable text like one from the info bar: 

/ P> Wedding - Venus: 17:00 - 2:00 Saturday: 12:00 - 2:00 Sun: 12:00 - 20:00

ago Thanks!

One way to do this is:.

Note: Something I have just written in a few minutes. If you are working with large amounts of data, then you have to customize accordingly.

  var rawFbData = {"wed_1_open": "17:00 "," Wed_1_close ":" 02: 00 "," thu_1_open ":" 17:00 "," thu_1_close ":" 02:00 "," fri_1_open ":" 17:00 "," fri_1_close ":" 02:00 "," Sat_1_open ":" 12: 00 "," set_1_clo ":" 02:00 "," sun_1_pennon ":" 12:00 "," sun_1_k L ":" 20:00 "}; Console.log (rawFbData); Var formatted data = {}; For (var key in rawFbData) {if (key.substr (-5) === '_open') {var openDay = key.substr (0, 3); Var opentime = rawfdfdata [key]; Var endimec = key.rele ('_Open', '_close'); Var endime = rawfobadata [andtamke]; Var formatteddata = opentime + '-' + overtime; If (formatted data [formatted data] === undefined) {formatted data [formatted data] = []; } Formatted data [formatted data]. Push (open); }} //console.log (formatted data); (Var formatted data in formatted data) {var formatted dataIlen = formatted data [FormatDate] Length; If (formattedDataIlen> 1) {var firstDay = formatted data [formatted data] [0]; Var final = formatted data [formatted data] [formatteddine-1]; Console.log (first day + '-' + last day ':' + formatted data); } And if (formatted data [formatted data] length === 1) {console.log (formatted data [formatted data] [0] + ':' + + formatted data); }}  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -