Mercurial > dive4elements > framework
annotate artifacts-common/src/main/java/de/intevation/artifacts/common/utils/JSON.java @ 436:15179c77aa1d flys-2.9.3
Documentation, so that readers know a tiny bit more what is going on.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 16 Oct 2012 15:08:43 +0200 |
parents | c40729bfe06d |
children |
rev | line source |
---|---|
381
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.artifacts.common.utils; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import java.util.Map; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 import java.util.LinkedHashMap; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import java.util.List; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import java.util.ArrayList; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import java.util.Iterator; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 import java.io.IOException; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 import java.io.PushbackInputStream; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import java.io.InputStream; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 import java.io.PrintWriter; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 import java.io.ByteArrayInputStream; |
384
823752e3d392
Fixed building XML documents from JSON strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
381
diff
changeset
|
14 import java.io.StringWriter; |
381
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import java.nio.charset.Charset; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 import java.nio.charset.UnsupportedCharsetException; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 public final class JSON |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 private JSON() { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 private static final boolean isDigit(int c) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 return c >= '0' && c <= '9'; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 public static final boolean isWhitespace(int c) { |
394
c40729bfe06d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
384
diff
changeset
|
29 return c == ' ' || c == '\n' || c == '\r' |
381
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 || c == '\t' || c == '\f'; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 private static final void match(int c, int x) throws IOException { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 if (c != x) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 throw new IOException( |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 "Expecting '" + (char)c + "' found '" + (char)x + "'"); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 private static final int eof(InputStream in) |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 throws IOException |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 int c = in.read(); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 if (c == -1) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 throw new IOException("EOF unexpected."); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 return c; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 private static final int whitespace(InputStream in) |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 throws IOException |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 int c; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 while (isWhitespace(c = eof(in))); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 return c; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 private static final int parseHex(String hex) throws IOException { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 try { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 return Integer.parseInt(hex, 16); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 catch (NumberFormatException nfe) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 throw new IOException("'" + hex + "' is not a hex string."); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 public static final String jsonString(String string) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 StringBuilder sb = new StringBuilder(string.length()+2); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 sb.append('"'); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 for (int i = 0, N = string.length(); i < N; ++i) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 char c = string.charAt(i); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 switch (c) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 case '"': sb.append("\\\""); break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 case '\t': sb.append("\\t"); break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 case '\r': sb.append("\\r"); break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 case '\n': sb.append("\\n"); break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 case '\b': sb.append("\\b"); break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 case '\f': sb.append("\\f"); break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 default: |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 if (c >= 128) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 sb.append("\\u"); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 String hex = Integer.toHexString((int)c); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 for (int j = 4-hex.length(); j > 0; --j) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 sb.append('0'); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 sb.append(hex); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 else { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 sb.append(c); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 sb.append('"'); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 return sb.toString(); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 |
384
823752e3d392
Fixed building XML documents from JSON strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
381
diff
changeset
|
101 public static String toJSONString(Map<String, Object> map) { |
823752e3d392
Fixed building XML documents from JSON strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
381
diff
changeset
|
102 StringWriter sw = new StringWriter(); |
823752e3d392
Fixed building XML documents from JSON strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
381
diff
changeset
|
103 PrintWriter pw = new PrintWriter(sw); |
823752e3d392
Fixed building XML documents from JSON strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
381
diff
changeset
|
104 write(pw, map); |
823752e3d392
Fixed building XML documents from JSON strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
381
diff
changeset
|
105 pw.flush(); |
823752e3d392
Fixed building XML documents from JSON strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
381
diff
changeset
|
106 return sw.toString(); |
823752e3d392
Fixed building XML documents from JSON strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
381
diff
changeset
|
107 } |
823752e3d392
Fixed building XML documents from JSON strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
381
diff
changeset
|
108 |
381
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 public static void write(PrintWriter out, Map<String, Object> map) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 writeObject(out, map); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 private static void writeValue(PrintWriter out, Object value) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 if (value instanceof Map) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 writeObject(out, (Map)value); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
118 else if (value instanceof List) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 writeList(out, (List)value); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 else if (value instanceof Number) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 out.print(value); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 else if (value instanceof Boolean) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 out.print(((Boolean)value) ? "true" : "false"); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
127 else if (value == null) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
128 out.print("null"); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
129 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
130 else { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
131 out.print(jsonString(value.toString())); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
133 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
134 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
135 private static void writeObject(PrintWriter out, Map map) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
136 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
137 out.print('{'); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 Iterator iter = map.entrySet().iterator(); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 while (iter.hasNext()) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 Map.Entry entry = (Map.Entry)iter.next(); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 out.print(jsonString(entry.getKey().toString())); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 out.print(':'); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
143 writeValue(out, entry.getValue()); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
144 if (iter.hasNext()) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 out.print(','); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 out.print('}'); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
149 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
150 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
151 private static void writeList(PrintWriter out, List list) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
152 out.print('['); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
153 Iterator iter = list.iterator(); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
154 while (iter.hasNext()) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
155 writeValue(out, iter.next()); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
156 if (iter.hasNext()) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
157 out.print(','); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
158 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
159 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
160 out.print(']'); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
161 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
162 |
394
c40729bfe06d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
384
diff
changeset
|
163 public static Map<String, Object> parse(String in) |
c40729bfe06d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
384
diff
changeset
|
164 throws IOException |
381
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
165 { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
166 return parse(asInputStream(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
167 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
168 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
169 private static InputStream asInputStream(String in) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
170 byte [] bytes; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
171 try { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
172 bytes = in.getBytes(Charset.forName("US-ASCII")); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
173 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
174 catch (UnsupportedCharsetException uce) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
175 // Should not happen. |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
176 bytes = in.getBytes(); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
177 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
178 return new ByteArrayInputStream(bytes); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
179 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
180 |
394
c40729bfe06d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
384
diff
changeset
|
181 public static Map<String, Object> parse(InputStream in) |
c40729bfe06d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
384
diff
changeset
|
182 throws IOException |
381
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
183 { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
184 return parseObject(new PushbackInputStream(in, 1)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
185 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
186 |
394
c40729bfe06d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
384
diff
changeset
|
187 public static Map<String, Object> parse(PushbackInputStream in) |
c40729bfe06d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
384
diff
changeset
|
188 throws IOException |
381
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
189 { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
190 return parseObject(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
191 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
192 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
193 private static final String parseString( |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
194 PushbackInputStream in |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
195 ) |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
196 throws IOException |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
197 { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
198 StringBuilder sb = new StringBuilder(); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
199 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
200 int mode = 0; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
201 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
202 char [] hex = new char[4]; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
203 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
204 match('"', eof(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
205 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
206 OUT: for (int c = eof(in);; c = eof(in)) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
207 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
208 switch (mode) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
209 case 0: |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
210 if (c == '"') { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
211 break OUT; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
212 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
213 if (c == '\\') { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
214 mode = 1; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
215 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
216 else { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
217 sb.append((char)c); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
218 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
219 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
220 case 1: |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
221 switch (c) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
222 case 'u': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
223 mode = 2; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
224 continue; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
225 case 'b': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
226 sb.append('\b'); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
227 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
228 case 'f': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
229 sb.append('\f'); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
230 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
231 case 'n': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
232 sb.append('\n'); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
233 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
234 case 'r': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
235 sb.append('\r'); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
236 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
237 case 't': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
238 sb.append('\t'); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
239 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
240 default: |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
241 sb.append((char)c); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
242 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
243 mode = 0; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
244 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
245 case 2: |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
246 hex[0] = (char)c; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
247 mode = 3; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
248 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
249 case 3: |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
250 hex[1] = (char)c; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
251 mode = 4; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
252 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
253 case 4: |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
254 hex[2] = (char)c; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
255 mode = 5; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
256 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
257 case 5: |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
258 hex[3] = (char)c; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
259 sb.append((char)parseHex(new String(hex))); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
260 mode = 0; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
261 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
262 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
263 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
264 return sb.toString(); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
265 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
266 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
267 private static final Boolean parseTrue(InputStream in) |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
268 throws IOException |
394
c40729bfe06d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
384
diff
changeset
|
269 { |
381
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
270 match('t', eof(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
271 match('r', eof(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
272 match('u', eof(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
273 match('e', eof(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
274 return Boolean.TRUE; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
275 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
276 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
277 private static final Boolean parseFalse(InputStream in) |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
278 throws IOException |
394
c40729bfe06d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
384
diff
changeset
|
279 { |
381
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
280 match('f', eof(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
281 match('a', eof(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
282 match('l', eof(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
283 match('s', eof(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
284 match('e', eof(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
285 return Boolean.FALSE; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
286 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
287 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
288 private static final Object parseNull(InputStream in) |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
289 throws IOException |
394
c40729bfe06d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
384
diff
changeset
|
290 { |
381
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
291 match('n', eof(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
292 match('u', eof(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
293 match('l', eof(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
294 match('l', eof(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
295 return null; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
296 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
297 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
298 private static final Number parseNumber(PushbackInputStream in) |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
299 throws IOException |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
300 { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
301 StringBuilder sb = new StringBuilder(); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
302 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
303 boolean isInteger = true; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
304 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
305 int c; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
306 OUT: for (;;) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
307 switch (c = eof(in)) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
308 case '0': case '1': case '2': case '3': case '4': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
309 case '5': case '6': case '7': case '8': case '9': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
310 case '-': case '+': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
311 sb.append((char)c); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
312 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
313 case '.': case 'e': case 'E': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
314 isInteger = false; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
315 sb.append((char)c); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
316 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
317 default: |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
318 in.unread(c); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
319 break OUT; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
320 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
321 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
322 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
323 try { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
324 if (isInteger) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
325 return sb.length() > 9 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
326 ? (Number)Long .valueOf(sb.toString()) |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
327 : (Number)Integer.valueOf(sb.toString()); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
328 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
329 return (Number)Double.valueOf(sb.toString()); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
330 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
331 catch (NumberFormatException nfe) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
332 throw new IOException("Not a number '" + sb + "'"); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
333 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
334 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
335 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
336 private static List<Object> parseList(PushbackInputStream in) |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
337 throws IOException |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
338 { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
339 List<Object> list = new ArrayList<Object>(); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
340 match('[', whitespace(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
341 int c = whitespace(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
342 if (c == ']') { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
343 return list; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
344 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
345 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
346 for (;; c = whitespace(in)) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
347 Object value; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
348 in.unread(c); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
349 switch (c) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
350 case '{': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
351 value = parseObject(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
352 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
353 case '[': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
354 value = parseList(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
355 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
356 case '"': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
357 value = parseString(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
358 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
359 case 't': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
360 value = parseTrue(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
361 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
362 case 'f': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
363 value = parseFalse(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
364 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
365 case 'n': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
366 value = parseNull(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
367 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
368 default: |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
369 value = parseNumber(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
370 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
371 list.add(value); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
372 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
373 if ((c = whitespace(in)) == ']') break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
374 match(',', c); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
375 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
376 return list; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
377 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
378 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
379 private static void parsePair( |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
380 PushbackInputStream in, |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
381 Map<String, Object> pairs |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
382 ) |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
383 throws IOException |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
384 { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
385 in.unread(whitespace(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
386 String string = parseString(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
387 match(':', whitespace(in)); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
388 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
389 Object value; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
390 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
391 int c = whitespace(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
392 in.unread(c); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
393 switch (c) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
394 case '{': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
395 value = parseObject(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
396 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
397 case '[': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
398 value = parseList(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
399 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
400 case '"': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
401 value = parseString(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
402 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
403 case 't': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
404 value = parseTrue(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
405 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
406 case 'f': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
407 value = parseFalse(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
408 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
409 case 'n': |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
410 value = parseNull(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
411 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
412 default: |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
413 value = parseNumber(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
414 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
415 pairs.put(string, value); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
416 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
417 |
394
c40729bfe06d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
384
diff
changeset
|
418 private static Map<String, Object> parseObject(PushbackInputStream in) |
381
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
419 throws IOException |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
420 { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
421 Map<String, Object> pairs = new LinkedHashMap<String, Object>(); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
422 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
423 int c = whitespace(in); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
424 match('{', c); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
425 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
426 if ((c = whitespace(in)) == '}') { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
427 return pairs; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
428 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
429 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
430 in.unread(c); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
431 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
432 for (;;) { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
433 parsePair(in, pairs); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
434 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
435 if ((c = whitespace(in)) == '}') { |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
436 break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
437 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
438 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
439 if (c == '}') break; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
440 match(',', c); |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
441 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
442 |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
443 return pairs; |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
444 } |
bed51de8ae58
Added JSON parser from Artefact Server NG to bridge from JSON to XML speaking services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
445 } |