KittyMac / Sextant

High performance JSONPath queries for Swift
MIT License
50 stars 5 forks source link

Replacing an integer with 1 yields a boolean in the replaced value #11

Open johnlabarge opened 1 week ago

johnlabarge commented 1 week ago

I replace a 1 using query(replace:jsonReplacement.at, with:replacementValue) where at is a path and replacement value is the integer 1 (a number). The replacement uses a boolean instead.

This is the offending line in the source: https://github.com/KittyMac/Sextant/blob/dbdbfa0f5230e728a50cf9ee1b21c5eea8144885/Sources/Sextant/Internal/Path/ObjectPropertyPath.swift#L12

Trying to determine a workaround.

KittyMac commented 1 week ago

can you provide example which illustrates the issue? I tried replacing a value with 1 and it worked as expected

    func test_an_array_can_be_updated2() {
        let json = #"[0,1,2,3]"#
        json.parsed { root in
            guard let root = root else { return }
            root.query(replace: "$[?(@ == 2)]", with: 1)
            XCTAssertEqual(root.description, #"[0,1,1,3]"#)
        }
    }