aboutsummaryrefslogtreecommitdiffstats
path: root/jsonfactory.py
blob: be70996fc8145d676fe9a2bcabc05f8a95831623 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import json


class JSONFactory(object):
    @staticmethod
    def make_object(text, user, timestamp, ip):
        message = json.dumps({
             "text": text,
             "user": user,
             "timestamp": timestamp,
             "ip": ip
        })

        return message

    @staticmethod
    def make_array(object_list):
        return "[\n" + ",\n".join(object_list) + "\n]"