INNER CODE UNIT · Python
send_cmd_to_socket
nordnet/next-api-v2-examples · python3/test_program.py:139
def send_cmd_to_socket(socket, cmd):
"""
Send commands to the feed through the socket
"""
socket.send(bytes(json.dumps(cmd) + '\n', 'utf-8'))
print("<< Sending cmd to feed: " + str(cmd))
def try_parse_into_json(string):
"""
Try parsing the string into JSON objects. Return the unparsable
parts as buffer
"""
json_strings = string.split('\n')
for i in range(0, len(json_strings)):
try:
json_data = json.loads(json_strings[i])
print(">> JSON updates from public feed")