Skip to content

Instantly share code, notes, and snippets.

@ItsSpyce
Created August 27, 2014 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ItsSpyce/cf0677be2fdc8d9b1e8c to your computer and use it in GitHub Desktop.
Save ItsSpyce/cf0677be2fdc8d9b1e8c to your computer and use it in GitHub Desktop.
public static string JsonifyAnon(this object input){
var model = input.ToString().Replace("=", ":");
var builder = new StringBuilder();
string[] keys;
object[] values;
foreach(var word in model.Split(' ')){
if (keys.Length == values) keys.Concat(new [] {String.Format("\"{0}\"", word)});
if (keys.Length >= values) {
if (word == "true") keys.Concat(new [] {"true"});
else if (word == "false") keys.Concat(new [] {"false"});
else {
if (Char.IsDigit(word)) keys.Concat(new [] {word});
else{
keys.Concat(new [] {String.Format("\"{0}\"", word)});
}
}
}
}
var i = 0;
while(i <= keys.Length){
if (i == 0) builder.Append("{")
builder.Append(String.Format("{0}:{1}"))
}
return builder.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment