JSON: ¿Por qué la web moderna se basa en él?
Si te mueves en el mundo de la TI, es probable que te hayas topado con las siglas JSON miles de veces. Pero, ¿qué es exactamente y por qué este formato ha desplazado al que alguna vez fue el popular XML? Hoy vamos a echar un vistazo 'bajo el capó' de este formato de datos ligero. změna
Mañana en el cañón. Coração e Ações.
What is JSON?
JSON (JavaScript Object Notation) es un formato de intercambio de datos basado en texto. Está diseñado para ser fácil de leer y escribir para los humanos, y al mismo tiempo, fácil de analizar y generar para las máquinas. A pesar de llevar "JavaScript" en su nombre, es independiente del lenguaje; hoy en día, es compatible con todo, desde Python y PHP hasta C#.
Si te mueves en el mundo de la TI, es probable que te hayas topado con las siglas JSON miles de veces. Pero, ¿qué es exactamente y por qué este formato ha desplazado al que alguna vez fue el popular XML? Hoy vamos a echar un vistazo 'bajo el capó' de este formato de datos ligero.
Si te mueves en el mundo de la TI, es probable que te hayas topado con las siglas JSON miles de veces. Pero, ¿qué es exactamente y por qué este formato ha desplazado al que alguna vez fue el popular XML? Hoy vamos a echar un vistazo 'bajo el capó' de este formato de datos ligero.
Si te mueves en el mundo de la TI, es probable que te hayas topado con las siglas JSON miles de veces. Pero, ¿qué es exactamente y por qué este formato ha desplazado al que alguna vez fue el popular XML? Hoy vamos a echar un vistazo 'bajo el capó' de este formato de datos ligero.
- test test
Why Does Everyone Love It?
- Minimalism: It doesn't contain any unnecessary tags.
- Speed: Thanks to its small footprint, data transfers at lightning speeds.
- Structure: It maps perfectly to common data structures like lists and objects.
What Does the Syntax Look Like?
JSON works with two fundamental structures:
- Object: A collection of key: value pairs enclosed in curly braces {}.
- Array: An ordered list of values enclosed in square brackets [].
Practical Example:
Imagine we are sending data about a user:
JSON
{
"id": 101,
"name": "John Doe",
"active": true,
"roles": ["admin", "editor"],
"address": {
"city": "Prague",
"zip": 11000
}
Data Types in JSON
In JSON, you can use the following value types:
- String – must always be in "double quotes."
- Number – both integers and floating-point numbers.
- Boolean – true or false.
- Array – a list of values.
- Object – nested data.
- Null – an empty value.
JSON vs. XML: Who Won?
XML used to be the primary choice for data transfer. Why do most developers choose JSON today?
| Feature | JSON | XML |
| Readability | Very higher | Lower (too many tags) |
| Size | Small (efficient) | Large |
| Parsing | fast (native in JS) | Slower |
| Typing | Supports numbers, boolean | Everything is text |
What to Watch Out For (Common Mistakes)
Even though JSON is simple, beginners often trip over details that can "break" an entire application:
- Missing quotes on keys: Keys must be in double quotes (e.g., "name": "John").
- Trailing commas: JSON cannot handle a comma after the last item in an object or array.
- Double vs. Single quotes: Only double quotes " are permitted in JSON.
JSON is indispensable today. Whether you are building a simple website or a complex mobile app, you can't live without it. It is the universal language of data, saving time for developers and resources for servers.
Want to know more: Connect via LinkedIn or check link