-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDecode.java
50 lines (30 loc) · 1.2 KB
/
Decode.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package robo;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
public class Decode {
public static float getPrice(String url) throws Exception {
float price = 0;
String values = GetRequest.sendGet(url);
System.out.println(values);
JSONObject jsonObject = new JSONObject();
Object obj=JSONValue.parse(values);
JSONArray array = (JSONArray)obj;
System.out.println(array.get(0));
JSONObject jsonObject2 = (JSONObject)array.get(0);
price = Float.parseFloat(jsonObject2.get("l_fix").toString());
return price;
}
public static float getChange(String url) throws Exception {
float price = 0;
String values = GetRequest.sendGet(url);
System.out.println(values);
JSONObject jsonObject = new JSONObject();
Object obj=JSONValue.parse(values);
JSONArray array = (JSONArray)obj;
System.out.println(array.get(0));
JSONObject jsonObject2 = (JSONObject)array.get(0);
price = Float.parseFloat(jsonObject2.get("cp_fix").toString());
return price;
}
}