Validate json file for correct format

Sarahrb

I need to validate if the selected Json file is valid (if in correct format). As some are missing closing bracket ']' at the end of file. How can I include validation here. I couldn't find a proper documentation that does this. Thank you.

    _loadedFile = e.File;       
    var utf8Json = _loadedFile.OpenReadStream(maxAllowedSize: 1024 * 1024 * 10); 
    var jsonDocument = await JsonDocument.ParseAsync(utf8Json);
    
T.Trassoudaine

Maybe TryParseValue can be used in your case

Otherwise you can use try/catch on JsonException.

Doc.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related