bookshop web service bookshop bookshop[book( 'xml''gryff smith' )book( 'java''phoebe cooke' )book( 'scala''adam davies' )book( 'python''jasmine byrne' )] encoding books into json one issue we have is that although the jsonify(function knows how to convert built in types such as stringsintegerslistsdictionaries etc into an appropriate json formatit does not know how to do this for custom types such as book we therefore need to define some way of converting book into an appropriate json format one way we could do this would be to define method that can be called to convert an instance of the book class into json format we could call this method to_json(for exampleclass book""represents book in the bookshop""def __init__(selfisbntitleauthorprice)self isbn isbn self title title self author author self price price def __str__(self)return self title by self author str(self pricedef to_json(self)return 'isbn'self isbn'title'self title'author'self author'price'self price we could now use this with the jsonify(function to convert book into the json formatjsonify({'book'book to_json()}