Disstructure assignment is a resource introduced in ECMAScript 2015 (ES6). He's basically a syntactic sugar to obtain object values or arrays.In your example, you're dismantling the properties title, description and value of the object request.body:const body = {
title: 'Sou o "Title"',
description: 'Sou a "Description"',
value: 'Sou o "Value"',
foo: 'Foo'
};
const { title, description, value } = body;
console.log(title, description, value);Note that the object may have more properties. We will only obtain, however, those that we destructure.As a comparison, to do the same thing in earlier versions of ES6, you would have to do:const body = {
title: 'Sou o "Title"',
description: 'Sou a "Description"',
value: 'Sou o "Value"',
foo: 'Foo'
};
const title = body.title;
const description = body.description;
const value = body.value;
console.log(title, description, value);Note that there is a significant line economy, which grows as we destructure more properties. Syntax goes far beyond that, see the https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Operators/Atribuicao_via_desestruturacao to learn more about the various use cases.There is also destructuring arrays. Here's a simple example:const arr = [1, 2, 3, 4, 5];
const [one, two] = arr;
console.log(one, two);Finally, it is important to say that this is not something "specific of JSON". JSON is a data transfer format compatible with JavaScript objects. So you can unstructure any object or array using these syntaxes. See the example below, which illustrates thestructuring of the property name of a function:function doStuff() {}
const { name } = doStuff;
console.log(O nome é: "${name}".);Anyway, it's a very useful addition that makes it easy to stick. https://pt.stackoverflow.com/questions/430322/o-que-s%c3%a3o-nomes-computados-em-javascript/430325#430325 explains how computed names work, a more complex resource of assignment via destructuring.