Repository navigation
Translate "JSON methods, toJSON" article to Portuguese #475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
|
|
||
| ```js run | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remoção da linha em branco inicial/final não faz parte da tradução e gera ruído no diff contra o upstream (dificulta sync futuro). Considere reverter as mudanças só de whitespace. |
||
| let room = { | ||
| number: 23 | ||
|
|
@@ -26,5 +25,4 @@ alert( JSON.stringify(meetup, function replacer(key, value) { | |
| */ | ||
| ``` | ||
|
|
||
| Here we also need to test `key==""` to exclude the first call where it is normal that `value` is `meetup`. | ||
|
|
||
| Aqui também precisamos testar `key==""` para excluir a primeira chamada, em que é normal que `value` seja `meetup`. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,13 +2,13 @@ importance: 5 | |||||
|
|
||||||
| --- | ||||||
|
|
||||||
| # Exclude backreferences | ||||||
| # Excluir referências cíclicas | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Título "referências cíclicas" destoa do corpo/artigo, que usam "referências circulares" em todo lugar. Sugestão para manter a terminologia consistente:
Suggested change
|
||||||
|
|
||||||
| In simple cases of circular references, we can exclude an offending property from serialization by its name. | ||||||
| Em casos simples de referências circulares, podemos excluir uma propriedade problemática da serialização pelo seu nome. | ||||||
|
|
||||||
| But sometimes we can't just use the name, as it may be used both in circular references and normal properties. So we can check the property by its value. | ||||||
| Mas às vezes não podemos simplesmente usar o nome, já que ele pode ser usado tanto em referências circulares quanto em propriedades normais. Então podemos verificar a propriedade pelo seu valor. | ||||||
|
|
||||||
| Write `replacer` function to stringify everything, but remove properties that reference `meetup`: | ||||||
| Escreva uma função `replacer` para transformar tudo em string, mas removendo propriedades que referenciam `meetup`: | ||||||
|
|
||||||
| ```js run | ||||||
| let room = { | ||||||
|
|
@@ -22,16 +22,16 @@ let meetup = { | |||||
| }; | ||||||
|
|
||||||
| *!* | ||||||
| // circular references | ||||||
| // referências circulares | ||||||
| room.occupiedBy = meetup; | ||||||
| meetup.self = meetup; | ||||||
| */!* | ||||||
|
|
||||||
| alert( JSON.stringify(meetup, function replacer(key, value) { | ||||||
| /* your code */ | ||||||
| /* seu código */ | ||||||
| })); | ||||||
|
|
||||||
| /* result should be: | ||||||
| /* o resultado deve ser: | ||||||
| { | ||||||
| "title":"Conference", | ||||||
| "occupiedBy":[{"name":"John"},{"name":"Alice"}], | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"e de volta" fica incompleto em português (de volta para quê?). Sugestão: