You can achieve this using a style tag with a conditional, see below:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "a",
"txtContent": "@currentField",
"attributes": {
"target": "_blank",
"href": "='https://contoso.sharepoint.com/w' + @currentField"
"style": {
"display": "=if(@currentField!='', 'block','none !important')",
}
}
Though personally, I like a good link icon, so I format mine like so:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "a",
"attributes": {
"target": "_blank",
"iconName": "Link",
"class": "sp-field-quickActions",
"href": "=if(@currentField!='',@currentField,''"
},
"style": {
"display": "=if(@currentField!='', 'block','none !important')",
"padding-left": "40px"
}
}
]
}
Hope that helps!