- Timestamp:
- Sep 10, 2014, 8:09:28 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/JSON/JSONString.cs
r162 r187 13 13 } 14 14 15 public override string ToString () 15 public string GetString () 16 { 17 return value; 18 } 19 20 public override string ToString (bool prettyPrint = false, int currentLevel = 0) 16 21 { 17 22 if (value == null || value.Length == 0) { … … 61 66 } 62 67 68 public static JSONString Parse (string json, ref int offset) 69 { 70 //Log.Out ("ParseString enter (" + offset + ")"); 71 StringBuilder sb = new StringBuilder (); 72 offset++; 73 while (offset < json.Length) { 74 switch (json [offset]) { 75 case '\\': 76 offset++; 77 switch (json [offset]) { 78 case '\\': 79 case '"': 80 case '/': 81 sb.Append (json [offset]); 82 break; 83 case 'b': 84 sb.Append ('\b'); 85 break; 86 case 't': 87 sb.Append ('\t'); 88 break; 89 case 'n': 90 sb.Append ('\n'); 91 break; 92 case 'f': 93 sb.Append ('\f'); 94 break; 95 case 'r': 96 sb.Append ('\r'); 97 break; 98 default: 99 sb.Append (json [offset]); 100 break; 101 } 102 offset++; 103 break; 104 case '"': 105 offset++; 106 //Log.Out ("JSON:Parsed String: " + sb.ToString ()); 107 return new JSONString (sb.ToString ()); 108 default: 109 sb.Append (json [offset]); 110 offset++; 111 break; 112 } 113 } 114 throw new MalformedJSONException ("End of JSON reached before parsing string finished"); 115 } 116 63 117 } 64 118 }
Note:
See TracChangeset
for help on using the changeset viewer.