Getting started with API Next - parsing RPC results?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aubergine
    Junior Member
    • Jan 2010
    • 19

    #1

    Getting started with API Next - parsing RPC results?

    Great news on the new API, very excited.

    JSONRPC looks like the way forward for me, but what do you suggest for converting RPC results to a domain model? Am I on my own here?
  • AlgoTrader
    Junior Member
    • Mar 2012
    • 243

    #2
    No need. Just use JSON results directly. Any JSON can be mapped to "object" and those objects are easy to use. But I recommend dynamic languages. In JavaScript for example things look like this

    Code:
    var response = JSON.parse(jsontext);
    if(response.result) {
        // call is OK
        for(market in response.result) {
            console.log("Market Id", market.marketId);
        }
    }
    The resume is you need no "types" to work with JSON-RPC in dynamic languages, JSON maps into objects "natively" in Python, JavaScript, PHP.

    If you have a market object, just make a method like
    Code:
    market.onListMarketBook(result);
    where result is deserialized JSON
    Betfair Bots Made Easy

    Comment

    Working...
    X