Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't correctly parse numbers immediately before a brace. #10

Closed
rickh57 opened this issue Feb 2, 2021 · 4 comments
Closed

Doesn't correctly parse numbers immediately before a brace. #10

rickh57 opened this issue Feb 2, 2021 · 4 comments

Comments

@rickh57
Copy link

rickh57 commented Feb 2, 2021

I'm using the covid-193.p.rapidapi.com. It returns JSON like this:

{"get":"statistics","parameters":{"country":"India"},"errors":[],"results":1,"response":[{"continent":"Asia","country":"India","population":1387975211,"cases":{"new":null,"active":164278,"critical":8944,"recovered":10448406,"1M_pop":"7757","total":10767206},"deaths":{"new":null,"1M_pop":"111","total":154522},"tests":{"1M_pop":"142475","total":197752057},"day":"2021-02-02","time":"2021-02-02T14:45:06+00:00"}]}

After parsing with JsonItem and dumping, I see this:

{
  "get" : "statistics",
  "parameters" : {
    "country" : "USA"
  },
  "errors" : ,
  "results" : 1,
  "response" : [
    {
      "continent" : "North-America",
      "country" : "USA",
      "population" : 332145637,
      "cases" : {
        "new" : "+1597",
        "active" : 9825868,
        "critical" : 23860,
        "recovered" : 16632858,
        "1M_pop" : "81028",
        "total" : 
      },
      "deaths" : {
        "new" : "+33",
        "1M_pop" : "1368",
        "total" : 
      },
      "tests" : {
        "1M_pop" : "945964",
        "total" : 
      },
      "day" : "2021-02-02",
      "time" : "2021-02-02T14:45:06+00:00"
    }
  ]
}

Numbers directly followed by ,, such as "recovered":10448406, are parsed OK. However, "total":154522} isn't parsed -- with an empty string being captured.

@StringEpsilon
Copy link
Owner

Thank you for the report. Should be fixed in the latest commit. I tested it with your file. Let me know whether or not it works for you.

@rickh57
Copy link
Author

rickh57 commented Feb 2, 2021

I commented on the commit, but I'll comment here, too. It's working fine now with the latest commit. I glanced at the code and was considering trying to fix it myself, but you certainly beat me to it.

@StringEpsilon
Copy link
Owner

You're brave. I wrote this library with no regard for maintainability or even comprehensibility.

@rickh57
Copy link
Author

rickh57 commented Feb 2, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants