Lines Matching +full:json +full:- +full:schema
2 * lws-api-test-lws_struct-json
4 * Written in 2010-2020 by Andy Green <andy@warmcat.com>
10 * linked-lists in a standardized way that's very modest on memory but
13 * The API test shows how to serialize and deserialize a struct with a linked-
14 * list of child structs in JSON using lws_struct APIs.
68 * We read the JSON config using lws_struct... instrument the related structures
107 LSM_SCHEMA (sai_jig_t, NULL, lsm_sai_jig, "sai-jig"),
112 "\"schema\": \"sai-jig\","
116 "\"name\": \"linkit-7697-1\","
161 * in this example, the JSON is for one "builder" object, which may specify
167 "\"schema\":\"com-warmcat-sai-builder\","
183 "\"schema\":\"com-warmcat-sai-builder\","
198 "\"schema\":\"com-warmcat-sai-builder\","
217 "\"schema\":\"com-warmcat-sai-builder\","
223 "\"schema\":\"com-warmcat-sai-builder\""
226 "\"schema\":\"com-warmcat-sai-builder\","
244 "\"schema\":\"com-warmcat-sai-builder\","
263 "{" /* test 8 the "other" schema */
264 "\"schema\":\"com-warmcat-sai-other\","
277 "{\"schema\":\"com-warmcat-sai-builder\",\"hostname\":\"learn\","
281 "{\"schema\":\"com-warmcat-sai-builder\",\"hostname\":\"learn\","
285 "{\"schema\":\"com-warmcat-sai-builder\",\"hostname\":\"learn\","
289 "{\"schema\":\"com-warmcat-sai-builder\","
292 "{\"schema\":\"com-warmcat-sai-builder\",\"hostname\":\"\","
295 "{\"schema\":\"com-warmcat-sai-builder\",\"hostname\":"
299 "{\"schema\":\"com-warmcat-sai-builder\",\"hostname\":\"\","
319 "{\"schema\":\"com-warmcat-sai-other\",\"name\":\"somename\"}"
359 /* the first kind of struct / schema we can receive */
379 * the second kind of struct / schema we can receive
397 * "schema": "meta",
414 LSM_SCHEMA (meta_t, NULL, lsm_meta, "meta.schema"),
418 * Schema table
421 * the schema, use the table below to create the right toplevel object for the
422 * schema name, and select the correct map tables to interpret the rest of the
426 * to receive, and we disambiguate and create the correct one using the schema
427 * JSON node.
429 * Therefore the schema table below is the starting point for the JSON
435 lsm_builder, "com-warmcat-sai-builder"),
437 lsm_other, "com-warmcat-sai-other"),
464 "{\"schema\":\"com.warmcat.sai.taskcan\","
502 lwsl_notice(" target.name '%s' (target %p)\n", t->name, t); in show_target()
504 if (t->child) in show_target()
506 t->child, t->child->somename); in show_target()
528 if ((p = lws_cmdline_option(argc, argv, "-d"))) in main()
532 lwsl_user("LWS API selftest: lws_struct JSON\n"); in main()
536 /* 1. deserialize the canned JSON into structs */ in main()
549 lwsl_err("%s: notification JSON decode failed '%s'\n", in main()
571 b->hostname, b->nspawn_timeout, in main()
572 b->targets.count); in main()
574 lws_dll2_foreach_safe(&b->targets, NULL, show_target); in main()
589 lwsl_notice("other.name = '%s'\n", o->name); in main()
592 /* 2. serialize the structs into JSON and confirm */ in main()
642 /* ad-hoc tests */ in main()
651 meta.t->name = "mytargetname"; in main()
652 lws_strncpy(meta.b->hostname, "myhostname", sizeof(meta.b->hostname)); in main()
656 lwsl_err("%s: failed to create json\n", __func__); in main()
667 "{\"schema\":\"meta.schema\"," in main()
693 lwsl_notice("%s: notification JSON decode failed '%s'\n", in main()
699 ((sai_cancel_t *)a.dest)->task_uuid); in main()
732 …if (strcmp("{\"schema\":\"com.warmcat.sai.taskinfo\",\"credentials\":[{\"ssid\":\"xxx\",\"passphra… in main()
786 lwsl_err("%s: line %d: JSON decode failed '%s'\n", in main()