Chris Muller uploaded a new version of JSON to project The Trunk: http://source.squeak.org/trunk/JSON-cmm.61.mcz
==================== Summary ====================
Name: JSON-cmm.61 Author: cmm Time: 18 February 2024, 6:01:50.22946 pm UUID: 9f100ce1-3d3c-4ea2-b975-4821175b41ba Ancestors: JSON-ct.58
Path access and enumeration for JSON objects.
=============== Diff against JSON-ct.58 ===============
Item was added: + ----- Method: Collection>>atPath: (in category '*json') ----- + atPath: anArray + "Assume I'm a set of nested HashedCollections and/or SequenceableCollections. Answer the object at the path of indices and/or keys identified in anArray." + ^ self + atPath: anArray + ifLost: [ : last | self error: 'path lost after' , last asString ]!
Item was added: + ----- Method: Collection>>atPath:ifLost: (in category '*json') ----- + atPath: anArray ifLost: aBlock + "Assume I'm a set of nested HashedCollections and/or SequenceableCollections. Answer the object at the path of indices and/or keys identified in anArray. If the full path specified by anArray isn't present, cull aBlock with the last element present along the path." + | last | + ^ (self + path: anArray + do: [ : elem : node | last := node ]) + ifNil: [ aBlock cull: last ] + ifNotNil: [ last ]!
Item was added: + ----- Method: Collection>>path:do: (in category '*json') ----- + path: anArray do: aBlock + "Assume I'm a set of nested HashedCollections and/or SequenceableCollections. Value aBlock with each object along the path of indices and/or keys identified in anArray. If a path element isn't found, stop, and return nil, otherwise, return self." + anArray + inject: self + into: + [ : dictOrArray : pathElem | dictOrArray + at: pathElem + ifPresent: [ : node | aBlock value: pathElem value: node ] + ifAbsent: [ ^ nil ] ]. + ^ self!
packages@lists.squeakfoundation.org