use dollar to prefix reserved JSON names
This commit is contained in:
parent
ae60be7644
commit
ffb24f5b59
@ -180,9 +180,9 @@ forget (const json_t *in)
|
|||||||
json_t *rx;
|
json_t *rx;
|
||||||
|
|
||||||
fg = json_object_get (in,
|
fg = json_object_get (in,
|
||||||
"_forgettable");
|
"$forgettable");
|
||||||
rx = json_object_get (in,
|
rx = json_object_get (in,
|
||||||
"_forgotten");
|
"$forgotten");
|
||||||
if (NULL != rx)
|
if (NULL != rx)
|
||||||
rx = json_deep_copy (rx); /* should be shallow
|
rx = json_deep_copy (rx); /* should be shallow
|
||||||
by structure, but
|
by structure, but
|
||||||
@ -292,7 +292,7 @@ forget (const json_t *in)
|
|||||||
if ( (NULL != rx) &&
|
if ( (NULL != rx) &&
|
||||||
(0 !=
|
(0 !=
|
||||||
json_object_set_new (ret,
|
json_object_set_new (ret,
|
||||||
"_forgotten",
|
"$forgotten",
|
||||||
rx)) )
|
rx)) )
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -321,6 +321,11 @@ TALER_JSON_contract_hash (const json_t *json,
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *enc = json_dumps (cjson,
|
||||||
|
JSON_ENCODE_ANY
|
||||||
|
| JSON_COMPACT
|
||||||
|
| JSON_SORT_KEYS);
|
||||||
ret = dump_and_hash (cjson,
|
ret = dump_and_hash (cjson,
|
||||||
NULL,
|
NULL,
|
||||||
hc);
|
hc);
|
||||||
@ -365,13 +370,13 @@ TALER_JSON_contract_mark_forgettable (json_t *json,
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
fg = json_object_get (json,
|
fg = json_object_get (json,
|
||||||
"_forgettable");
|
"$forgettable");
|
||||||
if (NULL == fg)
|
if (NULL == fg)
|
||||||
{
|
{
|
||||||
fg = json_object ();
|
fg = json_object ();
|
||||||
if (0 !=
|
if (0 !=
|
||||||
json_object_set_new (json,
|
json_object_set_new (json,
|
||||||
"_forgettable",
|
"$forgettable",
|
||||||
fg))
|
fg))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -419,22 +424,22 @@ TALER_JSON_contract_part_forget (json_t *json,
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
fg = json_object_get (json,
|
fg = json_object_get (json,
|
||||||
"_forgettable");
|
"$forgettable");
|
||||||
if (NULL == fg)
|
if (NULL == fg)
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||||
"Did not find _forgettable attribute trying to forget field `%s'\n",
|
"Did not find '$forgettable' attribute trying to forget field `%s'\n",
|
||||||
field);
|
field);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
rx = json_object_get (json,
|
rx = json_object_get (json,
|
||||||
"_forgotten");
|
"$forgotten");
|
||||||
if (NULL == rx)
|
if (NULL == rx)
|
||||||
{
|
{
|
||||||
rx = json_object ();
|
rx = json_object ();
|
||||||
if (0 !=
|
if (0 !=
|
||||||
json_object_set_new (json,
|
json_object_set_new (json,
|
||||||
"_forgotten",
|
"$forgotten",
|
||||||
rx))
|
rx))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
@ -99,7 +99,7 @@ test_contract (void)
|
|||||||
c1 = json_pack ("{s:s, s:{s:s, s:{s:s}}}",
|
c1 = json_pack ("{s:s, s:{s:s, s:{s:s}}}",
|
||||||
"k1", "v1",
|
"k1", "v1",
|
||||||
"k2", "n1", "n2",
|
"k2", "n1", "n2",
|
||||||
/***/ "_forgettable", "n1", "salt");
|
/***/ "$forgettable", "n1", "salt");
|
||||||
GNUNET_assert (NULL != c1);
|
GNUNET_assert (NULL != c1);
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_JSON_contract_mark_forgettable (c1,
|
TALER_JSON_contract_mark_forgettable (c1,
|
||||||
@ -116,7 +116,7 @@ test_contract (void)
|
|||||||
/* check salt was forgotten */
|
/* check salt was forgotten */
|
||||||
GNUNET_assert (NULL ==
|
GNUNET_assert (NULL ==
|
||||||
json_object_get (json_object_get (c1,
|
json_object_get (json_object_get (c1,
|
||||||
"_forgettable"),
|
"$forgettable"),
|
||||||
"k1"));
|
"k1"));
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_JSON_contract_hash (c1,
|
TALER_JSON_contract_hash (c1,
|
||||||
@ -162,9 +162,9 @@ test_contract (void)
|
|||||||
|
|
||||||
c1 = json_pack ("{s:I, s:{s:s}, s:{s:b, s:{s:s}}, s:{s:s}}",
|
c1 = json_pack ("{s:I, s:{s:s}, s:{s:b, s:{s:s}}, s:{s:s}}",
|
||||||
"k1", 1,
|
"k1", 1,
|
||||||
"_forgettable", "k1", "SALT",
|
"$forgettable", "k1", "SALT",
|
||||||
"k2", "n1", true,
|
"k2", "n1", true,
|
||||||
/***/ "_forgettable", "n1", "salt",
|
/***/ "$forgettable", "n1", "salt",
|
||||||
"k3", "n1", "string");
|
"k3", "n1", "string");
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_JSON_contract_hash (c1,
|
TALER_JSON_contract_hash (c1,
|
||||||
|
Loading…
Reference in New Issue
Block a user