Created
August 27, 2014 20:57
-
-
Save ItsSpyce/cf0677be2fdc8d9b1e8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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