c 23 is json valid

Solutions on MaxInterview for c 23 is json valid by the best coders in the world

showing results for - "c 23 is json valid"
Cécile
26 Feb 2018
1private static bool IsValidJson(string strInput)
2{
3    if (string.IsNullOrWhiteSpace(strInput)) { return false;}
4    strInput = strInput.Trim();
5    if ((strInput.StartsWith("{") && strInput.EndsWith("}")) || //For object
6        (strInput.StartsWith("[") && strInput.EndsWith("]"))) //For array
7    {
8        try
9        {
10            var obj = JToken.Parse(strInput);
11            return true;
12        }
13        catch (JsonReaderException jex)
14        {
15            //Exception in parsing json
16            Console.WriteLine(jex.Message);
17            return false;
18        }
19        catch (Exception ex) //some other exception
20        {
21            Console.WriteLine(ex.ToString());
22            return false;
23        }
24    }
25    else
26    {
27        return false;
28    }
29}
Haven
05 May 2019
1private static bool IsValidJson(string strInput)
2{//Using JSON.Net
3    if (string.IsNullOrWhiteSpace(strInput)) { return false;}
4    strInput = strInput.Trim();
5    if ((strInput.StartsWith("{") && strInput.EndsWith("}")) || //For object
6        (strInput.StartsWith("[") && strInput.EndsWith("]"))) //For array
7    {
8        try
9        {
10            var obj = JToken.Parse(strInput);
11            return true;
12        }
13        catch (JsonReaderException jex)
14        {
15            //Exception in parsing json
16            Console.WriteLine(jex.Message);
17            return false;
18        }
19        catch (Exception ex) //some other exception
20        {
21            Console.WriteLine(ex.ToString());
22            return false;
23        }
24    }
25    else
26    {
27        return false;
28    }
29}
30
31//or Without JSON.Net
32//You can utilize .Net framework 4.5 System.Json namespace ,like:
33
34string jsonString = "someString";
35try
36{
37    var tmpObj = JsonValue.Parse(jsonString);
38}
39catch (FormatException fex)
40{
41    //Invalid json format
42    Console.WriteLine(fex);
43}
44catch (Exception ex) //some other exception
45{
46    Console.WriteLine(ex.ToString());
47}//(But, you have to install System.Json through Nuget package manager using 
48//command: PM> Install-Package System.Json -Version 4.0.20126.16343 on Package Manager Console)
queries leading to this page
how to check json is valid or not in c 23how to check if string is a valid json c 23check json string valid c 23how to check if a string is a json c 23c 23 check valid jsonc 23 how to validate jsonvalidate json c 23c 23 check if tring is json formathow to check a json for text c 23check if string is valid json c 23 json validation c 23c 23 get if json is a valid c 23 objectcheck if string is json or not c 23 net check if string is jsonc 23 check if string valid jsonc 23 jsonproperty validatesethow to test if string is a valid json string c 23c 23 validate jsonc 23 json get if string is valit jsonjson string to valid c 23 stringc 23 validate json with object structuredetect a json netc 23 get if string is valid jsoncheck is json c 23c 23 validate json syntaxc 23 check if string is valid jsonc 23 check if json filehow to validate a json property in c 23how to check json string is correct or not in c 23c 23 check if jsonc 23 check if tring is valid json test if string is valid json c 23check object prarse in c 23c 23 how to validate if string is jsoncheck if file is json c 23validating json against an object in c 23c 23 check if data is jsoncheck string is jobject or jarrayvalidate if string is json c 23how to check whether a string is json or not in c 23jobject parse validate value examplevalidating json against a class in c 23c 23 check if is jsoncheck c 23 json objectcheck json is valid c 23validate string is json c 23valid json object example c 23check string is valid json c 23how to validate a value of a json property in c 23 net check if valid json genericc 23 string has jsonc 23 check if valid jsonhow to validate json in c 23newtonsoft check json validnewtonsoft json jsonconvert check if string is valid jsonc 23 validate json objectcheck if a string is valid json c 23c 23 is json validjson net check if valid jsonvalidate json checker c 23how to validate json response in c 23c 23 validate a string is in json formatc 23 check if string is jsonuse json to json string for testing c 23json validator netcheck if string is json c 23validate json format c 23check valid json c 23c 23 json validate stringc 23 check for valid jsonhow to validate a json in c 23validate json string c 23c 23 check if string is json newtonsoftcheck if string is json string c 23check if json is valid c 23how to valid json in c 23how to check json valid c 23validate if string is correct json c 23c 23 check if json is validhow to check if json string is json value in c 23c 23 is json valid