-1

I have a big jQuery data with the following format.

jQuery({locations: [,…], markersContent: [,…], sidebarContent: [,…]});

Is there a way to get the context of first part (locations) with python? I tried unsuccessfully different commands in PyQuery. Can anyone suggest a solution?

thanks

nakisa
  • 43
  • 1
  • 10
  • What's a "jQuery data"? jQuery isn't a data format, it's a Javascript library. – Daniel Roseman Mar 28 '17 at 13:41
  • Possible duplicate of [What is the difference between client-side and server-side programming?](http://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) – Jared Smith Mar 28 '17 at 14:11

1 Answers1

0

You can iterate through your JSON object. or if you have just single JSON inside it access it like

YOUR_VARIABLE['locations'].

If you have more then one json object inside your variable, you can iterate it like,

for key, value in YOUR_VARIABLE.items():
    print(key,value)

In that way, you can access your keys and values. Now if you have list inside value, you can iterate through that as well to extract those values.

Viraj
  • 228
  • 5
  • 14
  • Thanks for the answer, but it is unclear to me. I wrote this code : d = pq(url) print d('locations') ,but it does not work.The problem is how to extract the JSON object! – nakisa Mar 29 '17 at 08:08
  • Can you put your actual json variable and data here? – Viraj Mar 29 '17 at 08:24
  • URL = 'http://forms.polycom.com/php/st3/map_data.php?lat=48.1351253&lng=11.581980599999952&categoryid=&page_number=1&nb_display=10&radiusSelect=20&name=&city=Munich&country=Germany&state=&ptlevel=&milesKms=miles&industry=&jsonp_callback=jQuery111207484566748373911_1490620623208&_=1490620623210' – nakisa Mar 29 '17 at 12:40