Skip to content

Commit d5c2bf4

Browse files
authored
Update README.md - Remove legacy code ref
Also removed migration stuff. No longer needed.
1 parent 47149b5 commit d5c2bf4

File tree

1 file changed

+0
-36
lines changed

1 file changed

+0
-36
lines changed

README.md

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -103,42 +103,6 @@ val json5String = JSON5.stringify(data)
103103
// Returns: {name:'MyApp',version:2,enabled:true}
104104
```
105105

106-
### Migration from parseToAny (Deprecated)
107-
108-
If you were previously using the deprecated `parseToAny` method, here's how to migrate:
109-
110-
```kotlin
111-
val result = JSON5.parse("""{"key": "value"}""")
112-
when (result) {
113-
is JSON5Value.Object -> {
114-
val key = result.value["key"] as? JSON5Value.String
115-
println(key?.value) // "value"
116-
}
117-
}
118-
119-
// Alternative: Convert to raw objects when needed
120-
fun JSON5Value.toRawObject(): Any? {
121-
return when (this) {
122-
is JSON5Value.Null -> null
123-
is JSON5Value.Boolean -> this.value
124-
is JSON5Value.String -> this.value
125-
is JSON5Value.Number.Integer -> this.value.toDouble()
126-
is JSON5Value.Number.Decimal -> this.value
127-
is JSON5Value.Number.Hexadecimal -> this.value.toDouble()
128-
is JSON5Value.Number.PositiveInfinity -> Double.POSITIVE_INFINITY
129-
is JSON5Value.Number.NegativeInfinity -> Double.NEGATIVE_INFINITY
130-
is JSON5Value.Number.NaN -> Double.NaN
131-
is JSON5Value.Object -> this.value.mapValues { it.value.toRawObject() }
132-
is JSON5Value.Array -> this.value.map { it.toRawObject() }
133-
}
134-
}
135-
136-
// Using the helper for compatibility
137-
val rawResult = JSON5.parse("""{"key": "value"}""").toRawObject()
138-
val map = rawResult as Map<String, Any?>
139-
println(map["key"]) // "value"
140-
```
141-
142106
### Integration with kotlinx.serialization
143107

144108
```kotlin

0 commit comments

Comments
 (0)