以扭曲的dataReceivedparsing数据

我正在开发一个Sonos控制器的Kivy应用程序(在RPi上运行)。 东西的声纳方面是使用node.js。 我的kivy应用程序当前发送一个http请求来获取sonos(音量,电台,歌曲等)的状态,然后更新标签和图像。 这很好,但我想用扭曲。 作为一个起点,我正在运行kivy文档( https://kivy.org/docs/guide/other-frameworks.html )中的示例Echo Server应用程序。 当我运行它时,dataReceived正确地获取Sonos状态变化的当前状态信息。 这太棒了。 不幸的是,数据是文本和JSON的混合。 我想知道是否有一种方法来parsing返回的JSON。 这是数据

content-type:application / json content-length:1570 host:localhost:8000 connection:close

{“type”:“mute-change”,“data”:{“uuid”:“RINCON_000000000000001400”,“previousMute”:true,“previousMute”:false,“roomName”:“Office”}}

而不是使用dataReceived,有没有更好的方法? 我一直在寻找一种方式只是得到没有所有标题信息的JSON(身体),但没有发现很多工作。

TIA

使用扭曲的网页 。 例如:

from twisted.internet import reactor, endpoints from twisted.web.server import Site from twisted.web.resource import Resource import time class EchoPage(Resource): isLeaf = True def render_GET(self, request): return "I got: {}".format( request.content.read(), ) resource = EchoPage() factory = Site(resource) endpoint = endpoints.TCP4ServerEndpoint(reactor, 8880) endpoint.listen(factory) reactor.run()