AykutSarac / jsoncrack.com

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML, CSV and more, into interactive graphs.
https://jsoncrack.com/
Other
30.5k stars 1.89k forks source link

HTTP POST endpoint for sending JSON in the request body #160

Closed mculp closed 1 year ago

mculp commented 2 years ago

Feature

I have a use case where I would like to use this cool-ass tool programmatically. I would like to be able to POST a JSON payload and receive a URL to my cracked out JSON.

For this feature to be useful, there would need to be a way to to view a "crack" by ID.

I'm calling the resource cracks because that's what you called em.

This would be super simple to implement. Store the JSON in DynamoDB and return the ID.

Example

Request

POST /api/v1/cracks HTTP/1.1 Host: jsoncrack.com Accept: */* Content-Type: application/json Content-Length: 81

{ "a": { "b": [ { "id": 1, "name": "first" }, { "id": 2, "name": "second" } ] } }

Response

HTTP/1.1 201 Created Content-Type: application/json Content-Length: 144

{ "id": "2e5d5c18-fae3-482e-a4b8-dfba3a5fdfea", "status": "created", "url": "http://jsoncrack.com/cracks/2e5d5c18-fae3-482e-a4b8-dfba3a5fdfea" }

Alternative solutions or implementations

I suppose a workaround is to just link to or embed a giant query string with ?json=<huge document> but that seems unwieldy. Who wants to share a 5000 character url? Browsers do have limits on url length, also.

Other context

This could be an opt-in feature. It could be a feature for logged-in users only. Hell, it could be a premium feature. I'd pay a few bucks a month for this tool, especially if it had an API.

AykutSarac commented 1 year ago

Added with v2.5.0