Last change
on this file since 355 was 351, checked in by alloc, 6 years ago |
Fixed game version compatibility of GamePrefs
Code style cleanup (mostly argument names)
|
File size:
1.2 KB
|
Line | |
---|
1 | namespace AllocsFixes.JSON {
|
---|
2 | public class Parser {
|
---|
3 | public static JSONNode Parse (string _json) {
|
---|
4 | int offset = 0;
|
---|
5 | return ParseInternal (_json, ref offset);
|
---|
6 | }
|
---|
7 |
|
---|
8 | public static JSONNode ParseInternal (string _json, ref int _offset) {
|
---|
9 | SkipWhitespace (_json, ref _offset);
|
---|
10 |
|
---|
11 | //Log.Out ("ParseInternal (" + offset + "): Decide on: '" + json [offset] + "'");
|
---|
12 | switch (_json [_offset]) {
|
---|
13 | case '[':
|
---|
14 | return JSONArray.Parse (_json, ref _offset);
|
---|
15 | case '{':
|
---|
16 | return JSONObject.Parse (_json, ref _offset);
|
---|
17 | case '"':
|
---|
18 | return JSONString.Parse (_json, ref _offset);
|
---|
19 | case 't':
|
---|
20 | case 'f':
|
---|
21 | return JSONBoolean.Parse (_json, ref _offset);
|
---|
22 | case 'n':
|
---|
23 | return JSONNull.Parse (_json, ref _offset);
|
---|
24 | default:
|
---|
25 | return JSONNumber.Parse (_json, ref _offset);
|
---|
26 | }
|
---|
27 | }
|
---|
28 |
|
---|
29 | public static void SkipWhitespace (string _json, ref int _offset) {
|
---|
30 | //Log.Out ("SkipWhitespace (" + offset + "): '" + json [offset] + "'");
|
---|
31 | while (_offset < _json.Length) {
|
---|
32 | switch (_json [_offset]) {
|
---|
33 | case ' ':
|
---|
34 | case '\t':
|
---|
35 | case '\r':
|
---|
36 | case '\n':
|
---|
37 | _offset++;
|
---|
38 | break;
|
---|
39 | default:
|
---|
40 | return;
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 | throw new MalformedJSONException ("End of JSON reached before parsing finished");
|
---|
45 | }
|
---|
46 | }
|
---|
47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.