Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9269837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:13:20+00:00 2026-06-18T15:13:20+00:00

I am trying to get data from a nested java script structure. I want

  • 0

I am trying to get data from a nested java script structure. I want to use json.loads() for this. However, I am getting an error saying "No JSON object could be decoded"

Following is the code that I have tried out and the java script structure:
Code

page_us = urllib2.urlopen('http://www.verizonwireless.com/smartphones-2.shtml')

soup_us = BeautifulSoup(page_us)
scripts_us = soup_us.findAll('script')

script=[]
for s in scripts_us:
    if s.string and "$j('#module_1_Tile" in s.string:
        script.append(s.text.split('data')[1].replace("\n","").replace("(","").replace(")","").replace(";","").replace("\t",""))

Data Structure

script[1] = u'{"phones":{"id5986":{"id":"5986","rating":"stars_4","colorName":"White","colorCode":"#FFFFFF","capacity":"16 GB","price":"$149.99","fullPrice":"$599.99","addToCartQty":"0","image":"http://s7.vzw.com/is/image/VerizonWireless/Motorola%5Fdroid%5Frazr%5Fhd%5Fwhite?$device%2Dmed$","ATCST":"submitThisPhone","MAST":"false","CIL":"0","IRURL":"https://preorder.verizonwireless.com/iconic/","BAGX":"false","priceRange":"150","rating":"4","OOS":"","freeShipping":"freeOvernightShippingHTML","bagxGetPhone":"","badges":{"lteBadge","vzwExclusiveBadge","globalReadyBadge"},"vPrice":"$221.96","vFullPrice":"$671.96","vBundleName":"DROID RAZR HD by Motorola in White Bluetooth&reg Pack","vBundleImage":"http://s7.vzw.com/is/image/VerizonWireless/moto%5Fdroid%5Frazr%5Fhd%5Fwht%5Fbluetooth%5Fvirt%5Fbndl?$device%2Dmed$","vBundleDescription":"<ul><li>Bluetooth&reg Headset</li><li>Clear Hard Cover</li><li>Vehicle Charger</li></ul>"},"id5985":{"id":"5985","rating":"stars_4_5","colorName":"Black","colorCode":"#000000","capacity":"16 GB","price":"$149.99","fullPrice":"$599.99","addToCartQty":"0","image":"http://s7.vzw.com/is/image/VerizonWireless/Motorola%5Fdroid%5Frazr%5Fhd%5Fblack?$device%2Dmed$","ATCST":"submitThisPhone","MAST":"false","CIL":"0","IRURL":"https://preorder.verizonwireless.com/iconic/","BAGX":"false","priceRange":"150","rating":"4_5","OOS":"","freeShipping":"freeOvernightShippingHTML","bagxGetPhone":"","badges":{"lteBadge","vzwExclusiveBadge","globalReadyBadge"},"vPrice":"$221.96","vFullPrice":"$671.96","vBundleName":"DROID RAZR HD by Motorola Bluetooth&reg Pack","vBundleImage":"http://s7.vzw.com/is/image/VerizonWireless/moto%5Fdroid%5Frazr%5Fhd%5Fblk%5Fbluetooth%5Fvirt%5Fbndl?$device%2Dmed$","vBundleDescription":"<ul><li>Bluetooth&reg Headset</li><li>Silicone Cover</li><li>Vehicle Charger</li></ul>"}},"options":{"colorName":"Black","colorCode":"#000000","capacity":"16 GB"},"info":{"brand":"486","os":"10351","features":{502,569,501,568,247,318,85,503,497,431,458,11,49,150,44,17,141,145,165,20,58,15,24,172,186,184,159,187,185,199,156,249,157,189,142,168,211,13,188,239,14,167,321,41,25,357,443,441,442,444,459,418,416,12,413,5,61,7,446,504,362,573,202,522,"hasVB"},"priceRange":"150","phoneId":"id5985","ATCST":"submitThisPhone","MAST":"false","CIL":"0","IRURL":"https://preorder.verizonwireless.com/iconic/","bagxGetPhone":"","BAGX":"false"}}'

json.loads works fine for script[0], but gives the above error on script[1]. Please let me know what am I missing over here. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:13:22+00:00Added an answer on June 18, 2026 at 3:13 pm

    This section has curly braces instead of square brackets –

    {"lteBadge","vzwExclusiveBadge","globalReadyBadge"}
    

    Should be –

    ["lteBadge","vzwExclusiveBadge","globalReadyBadge"]
    

    You can use Python to help you identify these errors –

    >>> from ast import literal_eval
    >>> # Break it into lines to check location of error
    >>> s = data_structure.replace(',', ',\n')
    >>> literal_eval(s)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get my data from a query string, but use it
I am trying to use this function to pull data from Foursquare through yahoo
I'm trying to get a nested form view to update properly. This is however
So I'm trying to get data from my sql database and sort it by
I am trying to get data from my interface, written in c, to another
I'm trying to get some data from a certain web-based api using the libcurl
I'm trying to get character data from www.wowarmory.com using PHP and cURL. The code
I am trying to get data back from a PHP file assigned with GET
I'm trying to get some data from a table, where the tag has no
Using php I am trying to get some data from a .csv file which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.