Ejemplo n.º 1
0
def index():
    response = None
    format = "json"
    if request.method == "POST":
        format = request.form["format"]
        data = request.form["data"]

        try:
            if format == "vdf":
                response = json.dumps(
                    vdf.loads(data),
                    indent=4
                )

            elif format == "json":
                _response = json.loads(data)
                response = vdf.dumps(_response).decode("utf-16")

        except ValueError:
            flash("ValueError:  Your {} may not be valid.".format(format), "danger")
            response = "{}" if format == "json" else ""

    return render_template("vdfjson.html", response=response, format=format, title="vdfjson")
Ejemplo n.º 2
0
 def test_macro_quoted(self):
     self.assertEqual(self.EXPECTED_DICT, vdf.loads(self.MACRO_QUOTED_VDF))
Ejemplo n.º 3
0
 def test_quoted(self):
     self.assertEqual(self.EXPECTED_DICT, vdf.loads(self.QUOTED_VDF))
Ejemplo n.º 4
0
 def test_multikey_knode(self):
     self.maxDiff = 80 * 80
     self.assertEqual(self.EXPECTED_MULTIKEY_KNODE, vdf.loads(self.MULTIKEY_KNODE))
Ejemplo n.º 5
0
 def test_numerical_dict(self):
     self.assertEqual(self.EXPECTED_NUMERICAL_DICT, vdf.loads(vdf.dumps(self.NUMERICAL_DICT)))
Ejemplo n.º 6
0
 def test_subnode_dict(self):
     self.assertEqual(self.EXPECTED_SUBNODE_DICT, vdf.loads(vdf.dumps(self.SUBNODE_DICT)))
Ejemplo n.º 7
0
 def test_multikey_knode(self):
     self.maxDiff = 80*80
     self.assertEqual(self.EXPECTED_MULTIKEY_KNODE, vdf.loads(self.MULTIKEY_KNODE))
Ejemplo n.º 8
0
 def test_mixed(self):
     self.assertEqual(self.EXPECTED_MIXED_DICT, vdf.loads(self.MIXED_VDF))
Ejemplo n.º 9
0
 def test_simple_dict(self):
     self.assertEqual(self.EXPECTED_SIMPLE_DICT, vdf.loads(vdf.dumps(self.SIMPLE_DICT)))
Ejemplo n.º 10
0
 def test_mixed(self):
     self.assertEqual(self.EXPECTED_MIXED_DICT, vdf.loads(self.MIXED_VDF))
Ejemplo n.º 11
0
 def test_subnode_quoted(self):
     self.assertEqual(self.EXPECTED_SUBNODE_DICT, vdf.loads(self.SUBNODE_QUOTED_VDF))
Ejemplo n.º 12
0
 def test_comment_quoted(self):
     self.assertEqual(self.EXPECTED_DICT, vdf.loads(self.COMMENT_QUOTED_VDF))
Ejemplo n.º 13
0
 def test_macro_quoted(self):
     self.assertEqual(self.EXPECTED_DICT, vdf.loads(self.MACRO_QUOTED_VDF))
Ejemplo n.º 14
0
 def test_quoted(self):
     self.assertEqual(self.EXPECTED_DICT, vdf.loads(self.QUOTED_VDF))
Ejemplo n.º 15
0
 def test_comment_quoted(self):
     self.assertEqual(self.EXPECTED_DICT, vdf.loads(self.COMMENT_QUOTED_VDF))
Ejemplo n.º 16
0
 def test_subnode_quoted(self):
     self.assertEqual(self.EXPECTED_SUBNODE_DICT, vdf.loads(self.SUBNODE_QUOTED_VDF))
Ejemplo n.º 17
0
 def test_subnode_dict(self):
     self.assertEqual(self.EXPECTED_SUBNODE_DICT, vdf.loads(vdf.dumps(self.SUBNODE_DICT)))
Ejemplo n.º 18
0
 def test_multikey_kv(self):
     self.assertEqual(self.EXPECTED_MULTIKEY_KV, vdf.loads(self.MULTIKEY_KV))
Ejemplo n.º 19
0
 def test_array_dict(self):
     self.assertEqual(self.EXPECTED_ARRAY_DICT, vdf.loads(vdf.dumps(self.ARRAY_DICT)))
Ejemplo n.º 20
0
 def test_simple_dict(self):
     self.assertEqual(self.EXPECTED_SIMPLE_DICT, vdf.loads(vdf.dumps(self.SIMPLE_DICT)))
Ejemplo n.º 21
0
 def test_numerical_dict(self):
     self.assertEqual(self.EXPECTED_NUMERICAL_DICT, vdf.loads(vdf.dumps(self.NUMERICAL_DICT)))
Ejemplo n.º 22
0
 def test_array_dict(self):
     self.assertEqual(self.EXPECTED_ARRAY_DICT, vdf.loads(vdf.dumps(self.ARRAY_DICT)))
Ejemplo n.º 23
0
 def test_combination_dict(self):
     self.assertEqual(self.EXPECTED_COMBINATION_DICT, vdf.loads(vdf.dumps(self.COMBINATION_DICT)))
Ejemplo n.º 24
0
 def test_combination_dict(self):
     self.assertEqual(self.EXPECTED_COMBINATION_DICT, vdf.loads(vdf.dumps(self.COMBINATION_DICT)))
Ejemplo n.º 25
0
 def test_multikey_kv(self):
     self.assertEqual(self.EXPECTED_MULTIKEY_KV, vdf.loads(self.MULTIKEY_KV))