Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
JSON API / no braces
#1
Hello:

I'm new to Python. I'm using 3.5.3 on Windows.

Got a bit of a struggle with JSON where the data has no braces {} and only has brackets []. I'm unable to post the link (new to the forum, not a proven non-spammer). The data is from the US Census. The goal is to dump the extract onto a local text file. There are many of files I need to pull, so saving CSVs is not really an option.

Here is a sample of the data

[
  • [
    • "BIRTHS",
    • "YEAR",
    • "us"


  • ],


  • [
    • "3969976",
    • "2014",
    • "1"



  • ],


  • [
    • "3998730",
    • "2015",
    • "1"




  • ],


Based on the standard, it seems this is OK, if the data has no key.

The Python syntax below "bombs" when I assign it to the S variable using method "dump" for a string, so "dumps"


>>> import requests
>>> 
>>> response = requests.get("....census api call goes here with key....")
>>> import json


# bombs on this line below, everything above is OK
>>> s=json.dumps(response)


basically this comes back as is not JSON serializable ... from the standards, I understand why this is happening. I can't find a solution that will "serialize it."

Any thoughts would be appreciated. 

Thank you
Mariusz
Reply


Messages In This Thread
JSON API / no braces - by marucho21 - Feb-01-2017, 06:08 AM
RE: JSON API / no braces - by snippsat - Feb-01-2017, 07:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to output set items without the curly braces ? jimthecanadian 3 2,982 May-11-2019, 07:02 AM
Last Post: perfringo
  search and replace dots inside curly braces kchinnam 1 2,699 May-01-2018, 06:53 PM
Last Post: Larz60+
  No curly braces in python? RedSkeleton007 9 9,326 Jul-28-2017, 11:01 AM
Last Post: tony1812
  Are braces rather than indentation ever wanted? michaelcollier 22 14,509 May-02-2017, 08:37 AM
Last Post: volcano63

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020