Get JSON Data From Text using SQL

DECLARE
   @LeadID INT,
   @CompanyID INT,
   @Text VARCHAR(MAX) = ''


 (
 SELECT TOP 1 @Text = CAST(JsonData AS VARCHAR(MAX))
 FROM XeroLog 
 WHERE 
    CompanyID = @CompanyID AND 
    InvoiceID = '' AND 
    IsDeleted = 0 AND 
    JsonData IS NOT NULL
 )

 SELECT SUBSTRING(
    @Text, 
    CHARINDEX('{', @Text), 
    CHARINDEX(']  }', @text) - CHARINDEX('{', @Text) + Len(']  }')
 )

I am trying to retrieve JsonData from text I am using above query to retrieve data but I got this error message

Invalid length parameter passed to the LEFT or SUBSTRING function.

How to rectify this problem?