Supporting HATEOAS

Supporting HATEOAS

blacarblacar Posts: 2Questions: 1Answers: 0

Im new to datatables and wants to integrate with a server using spring-data-rest JSON HAL format
(https://tools.ietf.org/html/draft-kelly-json-hal-06)

Is this scenario supported in some way?

Can i custom parse the JSON response?

Thanks

Answers

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    Can i custom parse the JSON response?

    Use, use columns.data to tell DataTables what object property to read for each column.

    Perhaps if you could show an example of your JSON I might be able to provide a little more help.

    Allan

  • blacarblacar Posts: 2Questions: 1Answers: 0
    edited April 2015

    Thanks Allan,

    I need to consume HAL formatted responses like you can see below. If you are not familiar with HAL format it has three sections: 1st links that we can overpass, 2nd instant values and 3rd _embedded entities that holds also values we want to see.

    My problem it's with _embedded values ... i have no clear how to do that mapping

    The example is:

    {
        "_links": {
            "self": { "href": "/orders" },
            "curies": [{ "name": "ea", "href": "http://example.com/docs/rels/{rel}", "templated": true }],
            "next": { "href": "/orders?page=2" },
            "ea:find": {
                "href": "/orders{?id}",
                "templated": true
            },
            "ea:admin": [{
                "href": "/admins/2",
                "title": "Fred"
            }, {
                "href": "/admins/5",
                "title": "Kate"
            }]
        },
        "currentlyProcessing": 14,
        "shippedToday": 20,
        "_embedded": {
            "ea:order": [{
                "_links": {
                    "self": { "href": "/orders/123" },
                    "ea:basket": { "href": "/baskets/98712" },
                    "ea:customer": { "href": "/customers/7809" }
                },
                "total": 30.00,
                "currency": "USD",
                "status": "shipped"
            }, {
                "_links": {
                    "self": { "href": "/orders/124" },
                    "ea:basket": { "href": "/baskets/97213" },
                    "ea:customer": { "href": "/customers/12369" }
                },
                "total": 20.00,
                "currency": "USD",
                "status": "processing"
            }]
        }
    }
    
  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    If you are not familiar with HAL format

    Not at all - thanks for your introduction to it.

    My problem it's with _embedded values ... i have no clear how to do that mapping

    What do you want to get out of it. Is each ea:order a row in the table? If so then use ajax.dataSrc and set it to be _embedded.ea:order.

    Allan

This discussion has been closed.