Code Monkey home page Code Monkey logo

Comments (17)

royshil avatar royshil commented on August 21, 2024 1

The Windows build failed for now.

@Destroy666x windows build works now.

from obs-urlsource.

Destroy666x avatar Destroy666x commented on August 21, 2024 1

It's "Output Template" that's being rendered, right? First suggestion would be to turn that into a TextEdit textbox then. As from what I see inja loops have multiline syntax.

Another thing is how things are passed into the engine - e.g. array of objects seems to be text.

from obs-urlsource.

royshil avatar royshil commented on August 21, 2024 1

implemented in #39

from obs-urlsource.

Destroy666x avatar Destroy666x commented on August 21, 2024 1

@royshil example is like mentioned above:

[
  {
    "fact": "something"
  },
  {
    "fact": "else"
  }
]
  • JSON path: $[*].fact

body is for whole JSON output as the result is the same for the JSON path above and also for $ (root), even though results are different. Is there any way to have the JSON Path output as body or another variable? I don't think it's possible but I may have missed something.

I'd like to feed the result of that JSON Path to {{ join(body, " | ") }} as body

from obs-urlsource.

royshil avatar royshil commented on August 21, 2024

i think if i use https://github.com/pantor/inja it will enable everything and more
you can use loops and expressions in the {{ .. }}

from obs-urlsource.

Destroy666x avatar Destroy666x commented on August 21, 2024

Sounds good

from obs-urlsource.

royshil avatar royshil commented on August 21, 2024

implemented inja in #39

from obs-urlsource.

Destroy666x avatar Destroy666x commented on August 21, 2024

The Windows build failed for now.

from obs-urlsource.

royshil avatar royshil commented on August 21, 2024

i can just send the whole parsed response (in case of JSON) and you can use inja to manipulate it as you wish

from obs-urlsource.

Destroy666x avatar Destroy666x commented on August 21, 2024

Not sure about parsed response and how well Inja supports getting data out of it, but whole object/array would be nice for sure.

from obs-urlsource.

Destroy666x avatar Destroy666x commented on August 21, 2024

Any examples of how to do it with let's say this kind of JSON:

  [
    {
      "something": "something"
    },
    {
      "something": "else"
    }
  ]

?

And format it as something | else | ...

Not too sure how it was solved in the end looking at source.

from obs-urlsource.

Destroy666x avatar Destroy666x commented on August 21, 2024

Example:

[{"fact":"..."},{...}]

kind of output.

I'd expect:

{% for fact in output %}
  {{fact.fact}}
{% endfor %}

to cycle it, but I can't reall get it or anything similar to work. Also with body instead of output.

from obs-urlsource.

Destroy666x avatar Destroy666x commented on August 21, 2024

Ok, nvm, e.g.

{% for fact in body %}
  {{fact.fact}} |||||
{% endfor %}

is in fact working, but it's not fully stable, as I had to hide and show the source for it to be displayes, otherwise it just showed as is. Not too sure what's going on. But I think it's more of a problem with coming back to working state after inja errors out so I'll create a new bug and'll close this as finished.

from obs-urlsource.

Destroy666x avatar Destroy666x commented on August 21, 2024

I guess there's one more question. With the example above, if I use:

$[*].fact

body doesn't seem to change compared to $, it's still just the whole JSON. Is there any way to access that specific JSON path as an array or object specifically, just like body? So that you could use e.g. {{ join(array, " | ") }}

from obs-urlsource.

Destroy666x avatar Destroy666x commented on August 21, 2024

@royshil impossible, I assume?

from obs-urlsource.

royshil avatar royshil commented on August 21, 2024

@Destroy666x i'm not fully following you
can you provide a worked example? e.g. with the JSON body and the desired output?

from obs-urlsource.

royshil avatar royshil commented on August 21, 2024

@Destroy666x let's take this to another clean issue
just copy-paste plz

from obs-urlsource.

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.