mardi 24 février 2015

What is the correct way to determine type of string, xml, json, delimiter, name/value pair etc

How to determine type of string?


It can be either the following type types


1) Name/Value Pair


2) Delimiter


3) XML


4) JSON


5) Unknown (invalid)



public string GetValueByName (string Name)
{
//determine string type
//return the value
}


Is it ok if we did this for 3 (json), 4 (xml)?



For XML we can check if the first character is <, then we check if XML is valid
For JSON we can check if the first character is {, then we check if JSON is valid

Aucun commentaire:

Enregistrer un commentaire