File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed
src/commonMain/kotlin/io/github/optimumcode/json/pointer Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ public sealed class JsonPointer(
73
73
PointerParent (
74
74
parent,
75
75
node.propertyName,
76
+ node.index,
76
77
)
77
78
node = node.next
78
79
}
@@ -168,6 +169,7 @@ public sealed class JsonPointer(
168
169
private class PointerParent (
169
170
val parent : PointerParent ? ,
170
171
val segment : String ,
172
+ val index : Int? = null ,
171
173
)
172
174
173
175
private fun buildPath (
@@ -179,10 +181,18 @@ public sealed class JsonPointer(
179
181
while (parentValue != null ) {
180
182
curr =
181
183
parentValue.run {
182
- SegmentPointer (
183
- segment,
184
- curr,
185
- )
184
+ if (index == null ) {
185
+ SegmentPointer (
186
+ segment,
187
+ curr,
188
+ )
189
+ } else {
190
+ SegmentPointer (
191
+ segment,
192
+ curr,
193
+ index,
194
+ )
195
+ }
186
196
}
187
197
parentValue = parentValue.parent
188
198
}
@@ -269,12 +279,10 @@ private fun StringBuilder.appendEscaped(ch: Char) {
269
279
internal object EmptyPointer : JsonPointer()
270
280
271
281
internal class SegmentPointer (
272
- segment : String ,
282
+ val propertyName : String ,
273
283
override val next : JsonPointer = EmptyPointer ,
284
+ val index : Int = parseIndex(propertyName),
274
285
) : JsonPointer(next) {
275
- val propertyName: String = segment
276
- val index: Int = parseIndex(segment)
277
-
278
286
companion object {
279
287
private const val NO_INDEX : Int = - 1
280
288
private const val LONG_LENGTH_THRESHOLD = 10
You can’t perform that action at this time.
0 commit comments