Skip to content

Commit fb3264a

Browse files
authored
Merge pull request #619 from gratiaa/patch-7
[PR] Update article.md
2 parents c5bd5ca + 540ca28 commit fb3264a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

1-js/05-data-types/11-json/article.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ alert(json);
6666

6767
The method `JSON.stringify(student)` takes the object and converts it into a string.
6868

69-
The resulting `json` string is a called *JSON-encoded* or *serialized* or *stringified* or *marshalled* object. We are ready to send it over the wire or put into plain data store.
69+
The resulting `json` string is a called *JSON-encoded* or *serialized* or *stringified* or *marshalled* object. We are ready to send it over the wire or put into a plain data store.
7070

7171

72-
Please note that JSON-encoded object has several important differences from the object literal:
72+
Please note that a JSON-encoded object has several important differences from the object literal:
7373

7474
- Strings use double quotes. No single quotes or backticks in JSON. So `'John'` becomes `"John"`.
7575
- Object property names are double-quoted also. That's obligatory. So `age:30` becomes `"age":30`.
@@ -190,7 +190,7 @@ replacer
190190
space
191191
: Amount of space to use for formatting
192192

193-
Most of time, `JSON.stringify` is used with first argument only. But if we need to fine-tune the replacement process, like to filter out circular references, we can use the second argument of `JSON.stringify`.
193+
Most of the time, `JSON.stringify` is used with the first argument only. But if we need to fine-tune the replacement process, like to filter out circular references, we can use the second argument of `JSON.stringify`.
194194

195195
If we pass an array of properties to it, only these properties will be encoded.
196196

@@ -244,7 +244,7 @@ Now everything except `occupiedBy` is serialized. But the list of properties is
244244

245245
Fortunately, we can use a function instead of an array as the `replacer`.
246246

247-
The function will be called for every `(key,value)` pair and should return the "replaced" value, which will be used instead of the original one.
247+
The function will be called for every `(key, value)` pair and should return the "replaced" value, which will be used instead of the original one.
248248

249249
In our case, we can return `value` "as is" for everything except `occupiedBy`. To ignore `occupiedBy`, the code below returns `undefined`:
250250

@@ -281,7 +281,7 @@ number: 23
281281

282282
Please note that `replacer` function gets every key/value pair including nested objects and array items. It is applied recursively. The value of `this` inside `replacer` is the object that contains the current property.
283283

284-
The first call is special. It is made using a special "wrapper object": `{"": meetup}`. In other words, the first `(key,value)` pair has an empty key, and the value is the target object as a whole. That's why the first line is `":[object Object]"` in the example above.
284+
The first call is special. It is made using a special "wrapper object": `{"": meetup}`. In other words, the first `(key, value)` pair has an empty key, and the value is the target object as a whole. That's why the first line is `":[object Object]"` in the example above.
285285

286286
The idea is to provide as much power for `replacer` as possible: it has a chance to analyze and replace/skip the whole object if necessary.
287287

@@ -332,7 +332,7 @@ The `spaces` parameter is used solely for logging and nice-output purposes.
332332

333333
## Custom "toJSON"
334334

335-
Like `toString` for a string conversion, an object may provide method `toJSON` for to-JSON conversion. `JSON.stringify` automatically calls it if available.
335+
Like `toString` for string conversion, an object may provide method `toJSON` for to-JSON conversion. `JSON.stringify` automatically calls it if available.
336336

337337
For instance:
338338

@@ -409,7 +409,7 @@ str
409409
: JSON-string to parse.
410410

411411
reviver
412-
: Optional function(key,value) that will be called for each `(key,value)` pair and can transform the value.
412+
: Optional function(key,value) that will be called for each `(key, value)` pair and can transform the value.
413413

414414
For instance:
415415

@@ -521,7 +521,7 @@ alert( schedule.meetups[1].date.getDate() ); // works!
521521
## Summary
522522

523523
- JSON is a data format that has its own independent standard and libraries for most programming languages.
524-
- JSON supports plain objects, arrays, strings, numbers, booleans and `null`.
524+
- JSON supports plain objects, arrays, strings, numbers, booleans, and `null`.
525525
- JavaScript provides methods [JSON.stringify](mdn:js/JSON/stringify) to serialize into JSON and [JSON.parse](mdn:js/JSON/parse) to read from JSON.
526526
- Both methods support transformer functions for smart reading/writing.
527527
- If an object has `toJSON`, then it is called by `JSON.stringify`.

0 commit comments

Comments
 (0)