- Timestamp:
- Jan 19, 2019, 6:12:21 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/JSON/JSONArray.cs
r325 r351 6 6 private readonly List<JSONNode> nodes = new List<JSONNode> (); 7 7 8 public JSONNode this [int index] {9 get { return nodes [ index]; }10 set { nodes [ index] = value; }8 public JSONNode this [int _index] { 9 get { return nodes [_index]; } 10 set { nodes [_index] = value; } 11 11 } 12 12 … … 15 15 } 16 16 17 public void Add (JSONNode node) {18 nodes.Add ( node);17 public void Add (JSONNode _node) { 18 nodes.Add (_node); 19 19 } 20 20 21 public override void ToString (StringBuilder stringBuilder, bool prettyPrint = false, intcurrentLevel = 0) {22 stringBuilder.Append ("[");23 if ( prettyPrint) {24 stringBuilder.Append ('\n');21 public override void ToString (StringBuilder _stringBuilder, bool _prettyPrint = false, int _currentLevel = 0) { 22 _stringBuilder.Append ("["); 23 if (_prettyPrint) { 24 _stringBuilder.Append ('\n'); 25 25 } 26 26 27 27 foreach (JSONNode n in nodes) { 28 if ( prettyPrint) {29 stringBuilder.Append (new string ('\t',currentLevel + 1));28 if (_prettyPrint) { 29 _stringBuilder.Append (new string ('\t', _currentLevel + 1)); 30 30 } 31 31 32 n.ToString ( stringBuilder, prettyPrint,currentLevel + 1);33 stringBuilder.Append (",");34 if ( prettyPrint) {35 stringBuilder.Append ('\n');32 n.ToString (_stringBuilder, _prettyPrint, _currentLevel + 1); 33 _stringBuilder.Append (","); 34 if (_prettyPrint) { 35 _stringBuilder.Append ('\n'); 36 36 } 37 37 } 38 38 39 39 if (nodes.Count > 0) { 40 stringBuilder.Remove (stringBuilder.Length - (prettyPrint ? 2 : 1), 1);40 _stringBuilder.Remove (_stringBuilder.Length - (_prettyPrint ? 2 : 1), 1); 41 41 } 42 42 43 if ( prettyPrint) {44 stringBuilder.Append (new string ('\t',currentLevel));43 if (_prettyPrint) { 44 _stringBuilder.Append (new string ('\t', _currentLevel)); 45 45 } 46 46 47 stringBuilder.Append ("]");47 _stringBuilder.Append ("]"); 48 48 } 49 49 50 public static JSONArray Parse (string json, ref intoffset) {50 public static JSONArray Parse (string _json, ref int _offset) { 51 51 //Log.Out ("ParseArray enter (" + offset + ")"); 52 52 JSONArray arr = new JSONArray (); 53 53 54 54 bool nextElemAllowed = true; 55 offset++;55 _offset++; 56 56 while (true) { 57 Parser.SkipWhitespace ( json, refoffset);57 Parser.SkipWhitespace (_json, ref _offset); 58 58 59 switch ( json [offset]) {59 switch (_json [_offset]) { 60 60 case ',': 61 61 if (!nextElemAllowed) { 62 62 nextElemAllowed = true; 63 offset++;63 _offset++; 64 64 } else { 65 65 throw new MalformedJSONException ( … … 69 69 break; 70 70 case ']': 71 offset++;71 _offset++; 72 72 73 73 //Log.Out ("JSON:Parsed Array: " + arr.ToString ()); 74 74 return arr; 75 75 default: 76 arr.Add (Parser.ParseInternal ( json, refoffset));76 arr.Add (Parser.ParseInternal (_json, ref _offset)); 77 77 nextElemAllowed = false; 78 78 break;
Note:
See TracChangeset
for help on using the changeset viewer.