import static BotHoe.GrandExchangeApi.*;
public class Test {
public static void main(String[] args) {
GrandExchangeApi exchangeApi = new GrandExchangeApi();
GELookupResult lookupResult = exchangeApi.lookup(333);
if(lookupResult != null)
System.out.println("Item: " + lookupResult.name + " Price: " + lookupResult.price);
}
}
if
GrandExchangeApi exchangeApi = new GrandExchangeApi(false);
private static GELookupResult parse(int itemId, String json) {
Pattern pattern = Pattern.compile("\"(?<key>[^\"]+)\":\"(?<value>[^\"]+)\"");
Matcher m = pattern.matcher(json);
Map<String, String> results = new HashMap<>();
while(m.find()) {
results.put(m.group("key"), m.group("value"));
}
int price = 0;
Matcher priceMatcher = Pattern.compile("\"price\":(?<price>\\d+)").matcher(json);
if (priceMatcher.find()) {
price = Integer.parseInt(priceMatcher.group("price"));
}
Can someone explain?