<CCJson>.Valid

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Modules > cJSON > CCJson class > <CCJson> Properties >

<CCJson>.Valid

 

Description

 

Indicates whether the previously parsed JSON parse operation was valid.

 

Syntax

 

n = <CCJson>.Valid

 

Returns

 

Non-zero value for valid JSON.

 

Remarks

 

Restrictions

 

See also

 

.Parse

.ParseFile

 

Examples

 

uses "cjson""console"

 

dim json as new CCJson             ' Create an empty CCJson object

 

json.Parse("{'name': 'Eros'}")     ' Parse invalid JSON string

printl "Is valid?: " + json.Valid  ' Valid will return 0, because the JSON is invalid (because of usage of ' instead of ")

 

json.Parse("{""name"": ""Eros""}"' Parse JSON string to be further processed by json object

printl "Is valid?: " + json.Valid  ' Valid will return non-zero value, because the JSON is correct

 

waitkey