Find answers from the community

Updated 2 years ago

Json prompting

how can I use {"foo":{}, "bar":{}} in a prompt?
L
n
8 comments
Its not a bug, just a symptom of how string formatting works in python

I think you should be able to use double brackets?

{{"foo": {}, "bar":{}}}

Or if that doesn't work, the inner brackets might also need doubles, I forget how it works

{{"foo":{{}}, "bar":{{}}}}

Then when the string is formatted, the double brackets go away
I tried both of those
try it yourself
see if you can get it to work - I could not.
and I also thought at first it was my naïveté on how to use f strings
I had it working for one guy on the discord. When I get to my computer I'll give it a few tries
that would be amazing
Add a reply
Sign up and join the conversation on Discord