blob: d6b70b0f0ab8662fbf05d0b9e6aeed16e7382d26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# Slixmpp: The Slick XMPP Library
# Copyright (C) 2018 Maxime “pep” Buquet
# This file is part of Slixmpp.
# See the file LICENSE for copying permission.
import json
from slixmpp.xmlstream import ElementBase
class JSON_Container(ElementBase):
name = 'json'
plugin_attrib = 'json'
namespace = 'urn:xmpp:json:0'
interfaces = {'value'}
def get_value(self):
return json.loads(self.xml.text)
def set_value(self, value):
if not isinstance(value, str):
value = json.dumps(value)
self.xml.text = value
def del_value(self):
self.xml.text = ''
|