Converting segments from json to bicep #11041
-
When I'm editing bicep templates, I often look at what the Azure Portal API's are doing, extract the json and dump it in my bicep template. Manually converting json to bicep is quite a big pain, so I cobbled together this command to convert a selection in neovim editor from json to bicep, by removing quotes, converting, escaping quotes, removing comma's, et cetera 😄 Not sure if there is a better way for this, but it seems to do the job so far!
Would be cool to have this operation as a code action served by the LSP. So I select some json that I pasted in my bicep file and trigger a kind of best effort conversion to bicep syntax. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
In vscode there is a capability that you can use. "Paste JSON as Bicep" So long as the clipboard contains well formed json, then it works. Often it just takes wrapping it in {} or [] if it was not well formed, depending on what you copied. Just use the command pallette E.g. F1 or whatever shortcut you have mapped, then type "bicep: paste" it should show up. |
Beta Was this translation helpful? Give feedback.
-
I looked into it and seems like that feature is what I need, but I'm not using VS code. It appears that this feature is executed by the language server, so I can probably configure the command from my client in the same way it is done in VS code. Shouldn't be too difficult 😁 Thanks for the pointer |
Beta Was this translation helpful? Give feedback.
-
@brwilkinson Feels like I'm close; do you see anything very clearly wrong on what I"m doing here? The error is not very insightful at this point. 😄
|
Beta Was this translation helpful? Give feedback.
In vscode there is a capability that you can use. "Paste JSON as Bicep"
So long as the clipboard contains well formed json, then it works.
Often it just takes wrapping it in {} or [] if it was not well formed, depending on what you copied.
Just use the command pallette E.g. F1 or whatever shortcut you have mapped, then type "bicep: paste" it should show up.