Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/core/versions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ After shipping a .NET Core v1.0.0 stable version, patch-level changes (no new AP

You can see patch updates demonstrated in the project.json examples below.

```
```json
{
"dependencies": {
"Microsoft.NETCore.App": "1.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ string[] GetCities(string firstLetters);

If the operation takes an extra parameter, the request style must be wrapped to wrap both parameters in a single JSON object. An example of this style JSON message is in the following example.

```
```json
{"firstLetters": "na", "maxNumber": 2}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The readers and writers produced by the <xref:System.Runtime.Serialization.Json.

To clarify the concept of a mapping, the following example is of a JSON document.

```
```json
{"product":"pencil","price":12}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ http://example.com/myservice.svc/MyOperation?number=7&p={"name":"John","age":42}
#### XmlElement
<xref:System.Xml.XmlElement> is serialized as is, with no wrapping. For example, data member "x" of type <xref:System.Xml.XmlElement> that contains \<abc/> is as represented as follows.

```
```json
{"x":"<abc/>"}
```

Expand All @@ -178,7 +178,7 @@ http://example.com/myservice.svc/MyOperation?number=7&p={"name":"John","age":42}

To preserve type identity, when serializing complex types to JSON a "type hint" can be added, and the deserializer recognizes the hint and acts appropriately. The "type hint" is a JSON key/value pair with the key name of "__type" (two underscores followed by the word "type"). The value is a JSON string of the form "DataContractName:DataContractNamespace" (anything up to the first colon is the name). Using the earlier example, "Circle" can be serialized as follows.

```
```json
{"__type":"Circle:http://example.com/myNamespace","x":50,"y":70,"radius":10}
```

Expand All @@ -189,7 +189,7 @@ http://example.com/myservice.svc/MyOperation?number=7&p={"name":"John","age":42}
#### Reducing the Size of Type Hints
To reduce the size of JSON messages, the default data contract namespace prefix (http://schemas.datacontract.org/2004/07/) is replaced with the "#" character. (To make this replacement reversible, an escaping rule is used: if the namespace starts with the "#" or "\\" characters, they are appended with an extra "\\" character). Thus, if "Circle" is a type in the .NET namespace "MyApp.Shapes", its default data contract namespace is http://schemas.datacontract.org/2004/07/MyApp. Shapes and the JSON representation is as follows.

```
```json
{"__type":"Circle:#MyApp.Shapes","x":50,"y":70,"radius":10}
```

Expand All @@ -198,7 +198,7 @@ http://example.com/myservice.svc/MyOperation?number=7&p={"name":"John","age":42}
#### Type Hint Position in JSON Objects
Note that the type hint must appear first in the JSON representation. This is the only case where order of key/value pairs is important in JSON processing. For example, the following is not a valid way to specify the type hint.

```
```json
{"x":50,"y":70,"radius":10,"__type":"Circle:#MyApp.Shapes"}
```

Expand All @@ -219,13 +219,13 @@ http://example.com/myservice.svc/MyOperation?number=7&p={"name":"John","age":42}
#### Duplicate Data Member Names
Derived type information is present in the same JSON object together with base type information, and can occur in any order. For example, `Shape` may be represented as follows.

```
```json
{"__type":"Shape:#MyApp.Shapes","x":50,"y":70}
```

Whereas Circle may be represented as follows.

```
```json
{"__type":"Circle:#MyApp.Shapes","x":50, "radius":10,"y":70}
```

Expand All @@ -243,7 +243,7 @@ http://example.com/myservice.svc/MyOperation?number=7&p={"name":"John","age":42}
#### Collections Assigned to Object
Collections assigned to Object are serialized as if they are collections that implement <xref:System.Collections.Generic.IEnumerable%601>: a JSON array with each entry that has a type hint if it is a complex type. For example, a <xref:System.Collections.Generic.List%601> of type `Shape` assigned to <xref:System.Object> looks like the following.

```
```json
[{"__type":"Shape:#MyApp.Shapes","x":50,"y":70},
{"__type":"Shape:#MyApp.Shapes","x":58,"y":73},
{"__type":"Shape:#MyApp.Shapes","x":41,"y":32}]
Expand Down
2 changes: 1 addition & 1 deletion docs/framework/wcf/samples/json-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ser.WriteObject(stream1, p);

The memory stream contains valid JSON data.

```
```json
{"age":42,"name":"John"}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ When serializing a user-defined type to a given wire format, or deserializing a

For example, a public Web service API returns the following JSON object, which describes some information about a user of the service.

```
```json
{"personal": {"name": "Paul", "age": 23, "height": 1.7, "isSingle": true, "luckyNumbers": [5,17,21]}, "favoriteBands": ["Band ABC", "Band XYZ"]}
```

Expand Down