JSON
From the official website
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.
Introducing json (no date) JSON. Available at: https://www.json.org/json-en.html (Accessed: January 13, 2023).
It’s a serialisation format that is human-friendly, meaning objects, arrays and values are represented in a string. Example:
|
|
Here is a speculative object that could represent me in JSON.
This time, let’s say I have a array of users:
|
|
We can see that JSON has at least one drawback: the document’s structure and the data are mixed. You can see above that we repeat the keys id
, name
, surname
… for multiple users.
Is it possible to transfer a file over JSON?
Although protocols like REST and gRPC are more suitable for the task (with multipart upload and stream respectively), one could upload a file by encoding it in base64. Note that it increase the data size by ~33%1
T, D. and B, S. (2019) Posting a file and associated data to a restful webservice preferably as JSON, Stack Overflow. Available at: https://stackoverflow.com/a/4083908 (Accessed: January 5, 2023). ↩︎