question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redesign default .json format

See original GitHub issue

The default JSON just isn’t right. I find myself using ?_shape=array for almost everything I build against the API.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:48 (43 by maintainers)

github_iconTop GitHub Comments

3reactions
simonwcommented, Oct 20, 2020

Great point about CORS, I hadn’t considered that.

I think I’m going to keep the Link: header (added in #1014) because I quite enjoy using it with GitHub and WordPress, but I’m not going to have it be the default way of doing pagination. For the default shape I’m now leaning towards this:

{
  "total": 36,
  "rows": [{"id": 1, "name": "Cleo"}],
  "next_url": "https://latest-with-plugins.datasette.io/fixtures/facetable.json?_next=5"
}

So three keys: total, rows and next_url. Then extra keys can be added using ?_extra= with various named bundles.

2reactions
simonwcommented, Feb 20, 2021

OK, I’m back to the “top level object as the default” side of things now - it’s pretty much unanimous at this point, and it’s certainly true that it’s not a decision you’ll even regret.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON Formatter & Validator
The JSON Formatter & Validator beautifies and debugs JSON data with advanced formatting and validation algorithms.
Read more >
Redesign JSON output, ditch jsono, offer variants controlled ...
I want to support three variants for the rows output: a list of lists, with a columns key saying what they are a...
Read more >
Default JSON Result Format - Vespa Documentation
The default JSON result format is used when presentation.format is unset or set to json . Results are rendered with one or more...
Read more >
JSON And BSON - MongoDB
Learn how MongoDB uses the lightweight and flexible BSON, an extension JSON, to maximize efficiency for programming languages.
Read more >
Best practices for REST API design - Stack Overflow Blog
JSON is a concise, fairly readable, widely used format for data persistence and transfer. Also, it's in fashion. So it's a good “go...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found