Closed rafalwojcik closed 1 year ago
I think there's precedent for specifying the index inside square brackets.
@JetForMe no need to specify square brackets. If a nested object is not array it will start looking for 0
as key. I think it is the right behavior.
This PR adds a new feature of getting the object at a particular index by keyPath. Let's say that we have JSON like this:
Right now is not possible to parse just first object from category array. After my change you can use index in keypath like this:
category = try object.value(for: "categories.0")
this will take a look inside array if object at keycategories
is array if not it will raise exception or follow keyPath as string value of0
.