Hi
Like isBase64 posted here
https://www.b4x.com/android/forum/threads/check-if-a-string-is-base64-isbase64.98444/
here is the isJson function based on JSON documentation
example of use
The result log is
true
false
Credits: stackoverflow, Douglas Farias and JSON documentation
Like isBase64 posted here
https://www.b4x.com/android/forum/threads/check-if-a-string-is-base64-isbase64.98444/
here is the isJson function based on JSON documentation
B4X:
Sub is_Json(json As String) As Boolean
If Regex.IsMatch($"[{\[]{1}([,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}"$, json.Trim) And json.Length > 2 Then
Return True
Else
Return False
End If
End Sub
example of use
B4X:
Log(is_Json($"{"success":false,"msg":"teste!"}"$))
Log(is_Json($"{"success":false,"msg":"$))
The result log is
true
false
Credits: stackoverflow, Douglas Farias and JSON documentation
Last edited: