Giter Club home page Giter Club logo

Comments (7)

btiernay avatar btiernay commented on June 14, 2024

Any ideas why this might be happening? I'd be willing to help create a fix if I could get some pointers. Thanks!

from jackson-jq.

eiiches avatar eiiches commented on June 14, 2024

@btiernay I'm sorry to have kept you waiting, I'll try to look closely into the problem this weekend.

from jackson-jq.

eiiches avatar eiiches commented on June 14, 2024

Sorry for my late response, I'm currently working on a fix.

The problem was that we cannot determine which part of an input JsonNode to update because in the current implementation we only handled a simple FieldAccess like .a[0].a in assignments.

In btiernay's example, we have an input {"x": 1} and (..|numbers) evaluates to 1. Then we apply += 1 against 1 and get 2. But where in {"x": 1} we should put this 2 back, we do not know now.

I'm trying to fix this by creating a simple wrapper around JsonNode and wrapping an input before evaluating assignment expressions. So far (..|numbers) += 1 worked, but test cases (such as jq '.[1] = 1' <<< '[]', in which a non-existent element of an input array or object is accessed) started to fail and still working on a fix.

from jackson-jq.

btiernay avatar btiernay commented on June 14, 2024

Thanks for your support, much appreciated!

from jackson-jq.

mdbhat avatar mdbhat commented on June 14, 2024

I am facing a similar issue. Do we have a solution for this? My rule works fine in jqplay but I get this error in java.
net.thisptr.jackson.jq.exception.IllegalJsonArgumentException: left hand side must be FieldAccess
at net.thisptr.jackson.jq.internal.tree.binaryop.assignment.UpdateAssignment.apply(UpdateAssignment.java:28)
at net.thisptr.jackson.jq.internal.tree.PipedQuery.applyRecursive(PipedQuery.java:42)
at net.thisptr.jackson.jq.internal.tree.PipedQuery.apply(PipedQuery.java:25)
at net.thisptr.jackson.jq.internal.IsolatedScopeQuery.apply(IsolatedScopeQuery.java:21)
at net.thisptr.jackson.jq.JsonQuery.apply(JsonQuery.java:20)

from jackson-jq.

mdbhat avatar mdbhat commented on June 14, 2024

It worked for me by making this change in the rule
(. |= (. + if has("dataSource") then {("newDataSource"): .dataSource} else . end)) | del(.dataSource)
New rule:
(. + if has("dataSource") then {("newDataSource"): .dataSource} else . end) | del(.dataSource)

from jackson-jq.

eiiches avatar eiiches commented on June 14, 2024

This long-standing issue has been resolved in 1.0.0-preview.* versions.

from jackson-jq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.