You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Attributes/PhpProperty.md
+64-8Lines changed: 64 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -4,18 +4,40 @@
4
4
5
5
**Table of contents**
6
6
1.[PhpProperty](#PhpProperty)
7
+
1. [Signatures](#signatures)
8
+
1.[Examples](#Examples)
7
9
1. [Example 1: Serialize](#Example-1:-Serialize)
8
-
2. [Example 2: Deserialize with classname](#Example-1:-Deserialize-with-classname)
9
-
3. [Example 3: Deserialization with actual name.](#Example-1:-Deserialize-with-actual-name)
10
+
2. [Example 2: Serialize with integer keys](#Example-1:-Serialize)
11
+
3. [Example 3: Deserialize with classname](#Example-3:-Deserialize)
12
+
4. [Example 4: Deserialization with actual name.](#Example-4:-Deserialization-with-actual-name)
13
+
4. [Example 5: Deserialize with integer names](#Example-5:-Deserialize-with-integer-names)
10
14
11
-
---
12
15
13
16
# PhpProperty
14
17
15
18
Specifiy the name of the property in the serialization data, for both serialization and deserialization.
16
19
17
20
Please be aware that the actual name of the property may be used as a fallback for assignment. See [example 3](#Example-1:-Deserialize-with-actual-name).
18
21
22
+
## Signatures
23
+
24
+
You can use the PhpProperty attribute with both a string and an integer argument.
25
+
26
+
```cs
27
+
[PhpProperty("string")]
28
+
```
29
+
30
+
```cs
31
+
[PhpProperty(42)]
32
+
```
33
+
34
+
Indicating that the de/serialization should use the string and integer values as the key for the property respectively.
35
+
36
+
**Important**:
37
+
Deserialization of objects and arrays with integer keys may yield unexpected results and or exceptions on certain target types. `PhpObjectDictionary` and `PhpDynamicObject` only supports string keys, for example, and will throw an exception.
38
+
39
+
# Examples
40
+
19
41
## Example 1: Serialize
20
42
21
43
@@ -34,8 +56,26 @@ var serialized = PhpSerialization.Serialize(
A dynamic object that can hold any property, used for deserializing object notation while providing a way to access the specified classname.
11
11
12
+
**Important**:
13
+
14
+
`PhpObjectDictionary` only supports string keys. You can not deserialize PHP objects with integer keys using this type. This may be addressed in future releases.
`PhpObjectDictionary` only supports string keys. You can not deserialize PHP objects with integer keys using this type. This may be addressed in future releases.
0 commit comments