-2

I'm working on a little economics project in Java and looking for somebody who's worked with JSON before to help me overcome my current hurdle.

I have a real-time JSON database with thousands of elements that each have buy and sell prices.

http://www.rsbuddy.com/exchange/summary.json

Below is the first of the elements from that JSON

"2": {
    "overall_average": 198,
    "buy_average": 197,
    "id": 2,
    "sp": 5,
    "sell_average": 199,
    "members": true,
    "name": "Cannonball"
}

What I'd like to do is have a little Java code that runs through all of the elements and returns only the elements with a 'buy/sell margin' (so 'buy_average' minus 'sell_average') that is greater than 1,000.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Yawodo
  • 1
  • 3
  • consider [Google GSON](https://github.com/google/gson) or another JSON serializer/deserializer, to convert your json to java objects. As you have converted your json, process the data inside of your objects as you want. –  Apr 13 '17 at 12:42
  • 1
    1) This isn't a forum 2) This isn't a "hire a coder to do this for me" site – OneCricketeer Apr 13 '17 at 13:14

1 Answers1

1

I recommend Gson.

    import com.google.gson.Gson;
. . . 
        Gson GSON = new Gson();
         List<Map<String, Object>> search = ...
            String json = GSON.toJson(search);

it's a very intuitive utility...

heres the maven ref

 <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.0</version>
        </dependency>
Mark Giaconia
  • 3,844
  • 5
  • 20
  • 42