GithubHelp home page GithubHelp logo

eval - cannot get a single value about eel HOT 6 CLOSED

comcast avatar comcast commented on August 10, 2024
eval - cannot get a single value

from eel.

Comments (6)

boriwo avatar boriwo commented on August 10, 2024 1

The data under total is not a map but and array with a single map element, so you must access the array item by its index. This should work: {{/result/total[0]/qty}}

from eel.

boriwo avatar boriwo commented on August 10, 2024 1

Yes, in a situation like this you can also pull an array element by key-value-pair present in the element. The syntax works like this: {{/result/total[assetref=18-265-55833]/qty}}

from eel.

boriwo avatar boriwo commented on August 10, 2024

Do you have a specific example? eval() lets you select maps, arrays and simple types from json documents. Example of a single value selection:

{{eval('/foo','{"foo":"bar"}')}}

from eel.

albabosh avatar albabosh commented on August 10, 2024

This is my case:

"Transformation": {
"{{/result}}" : "{{eval('/result/total/qty','{{prop('noderesponse')}}')}}",
"{{/error}}" : "{{eval('/error','{{prop('noderesponse')}}')}}",
"{{/id}}" : "{{eval('/id','{{prop('noderesponse')}}')}}",
"{{/check}}" : "{{eval('/','{{prop('noderesponse')}}')}}"
},

Response:

{
"check":{
"error": null,
"id": null,
"result":{
"1Gcv7PgJX8kg2zd6SMYq2shotah9H94r7bc61s":[
{"assetref": "18-265-55833", "name": "RURT", "qty": 94}
],
"total":[
{"assetref": "18-265-55833", "name": "RURT", "qty": 94}
]
}
},
"error": "",
"id": "",
"result": ""
}

The problem: eval does not return a single value (or maybe I am doing it the wrong way)

from eel.

albabosh avatar albabosh commented on August 10, 2024

P.S. Maybe it was a bit unclear, but I need "total" quantity ("qty") from where "assetref":"18-265-55833"

from eel.

albabosh avatar albabosh commented on August 10, 2024

Thanks, that really works. But I am not sure it has index [0], is there any way to get an item with "assetref":"18-265-55833" exactly ?

from eel.

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.