const struct json_attr_t json_attrs_subdevice[] = {
{"path", t_string, STRUCTOBJECT(struct devconfig_t, path),
.len = sizeof(devicelist.list[0].path)},
- {"activated", t_time, STRUCTOBJECT(struct devconfig_t, activated)},
{"activated", t_real, STRUCTOBJECT(struct devconfig_t, activated)},
{NULL},
};
+t_character+: Accept a single-character JSON string literal, copy
that character to a C +char+ location.
-+t_time+: Accept a string in the format of an RFC3339 UTC date with
-optional fractional decimal seconds, interpret as seconds since
-the Unix epoch UTC, store in a C double location..
-
Associated with each simple value type's storage (in the +addr+
union) is a correspondingly-named field in the +dflt+ union).
This is a default value which is copied to the target storage
#include <limits.h>
#include <string.h>
+
#include "mjson.h"
#define MAXUSERDEVS 4
const struct json_attr_t json_attrs_subdevice[] = {
{"path", t_string, STRUCTOBJECT(struct devconfig_t, path),
.len = sizeof(devicelist.list[0].path)},
- {"activated", t_time, STRUCTOBJECT(struct devconfig_t, activated)},
{"activated", t_real, STRUCTOBJECT(struct devconfig_t, activated)},
{NULL},
};
--------------------------------------------------------
$ example3 '{"devices":[{"path":"/dev/ttyUSB0",
- "activated":"2014-09-23T10:32:20"}]}'
+ "activated":1411468340}]}'
1 devices:
/dev/ttyUSB0 @ 1411468340.000000
--------------------------------------------------------
The dialect this parses has some limitations. First, it cannot
recognize the JSON "null" value. Second, all elements of an array must
-be of the same type. Third, some types (t_time, t_character) may not
-be array elements (this restriction could be lifted, and might be
-in a future release).
+be of the same type. Third, t_character may not be an array element
+(this restriction could be lifted, and might be in a future release).
There are separate entry points for beginning a parse of either JSON
object or a JSON array.