Skip to content

Instantly share code, notes, and snippets.

@CoalaJoe
Created May 3, 2017 07:10
Show Gist options
  • Save CoalaJoe/8a67b410062e40afc3b8414af91ca79e to your computer and use it in GitHub Desktop.
Save CoalaJoe/8a67b410062e40afc3b8414af91ca79e to your computer and use it in GitHub Desktop.
import re
import json
running_game = r"""
Here some nice debugging message.
{ "type": "device",
"statusLine": "200 Ok",
"statusCode": "200",
"status": "Ok",
"host-id": "BC60A766BA99",
"host-type": "PS4",
"host-name": "PS4",
"host-request-port": "997",
"device-discovery-protocol-version": "00020020",
"system-version": "04550011",
"running-app-name": "Curses 'N Chaos",
"running-app-titleid": "CUSA03106",
"address": "192.168.1.75" }
Another one right here.
"""
# Get data between {}.
game_data = re.findall(r'{([^]]*)}', running_game)[0]
game_data = '{%s}' % game_data
the_actual_data = json.loads(game_data)
print(the_actual_data['running-app-name'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment