json_07_nested_arrays.ksh revision 37c79205ad46187f54b2edbf6a468160935f14d9
2N/A#!/bin/ksh
2N/A#
2N/A# This file and its contents are supplied under the terms of the
2N/A# Common Development and Distribution License ("CDDL"), version 1.0.
2N/A# You may only use this file in accordance with the terms of version
2N/A# 1.0 of the CDDL.
2N/A#
2N/A# A full copy of the text of the CDDL should have accompanied this
2N/A# source. A copy of the CDDL is also available via the Internet at
2N/A# http://www.illumos.org/license/CDDL.
2N/A#
2N/A
2N/A#
2N/A# Copyright (c) 2014, Joyent, Inc.
2N/A#
2N/A
2N/ADIR=$(dirname $(whence $0))
2N/A. ${DIR}/json_common
2N/A
2N/ABASELINE="$(cat <<EOF
2N/A{\
2N/A"event_store":{\
2N/A"name":"Occurences",\
2N/A"events":[\
2N/A{"time":489715200,"desc":"inception"},\
2N/A{"time":1057708800,"desc":"maturation"},\
2N/A{"time":1344816000,"desc":"migration"},\
2N/A{"time":1405296000,"desc":"integration"},\
2N/A{}\
2N/A]\
2N/A},\
2N/A"first level":[\
2N/A{"second_level_0":[{\
2N/A"sl0_a":true,\
2N/A"sl0_b":"aaaa"\
2N/A},\
2N/A{"x":1234}\
2N/A],\
2N/A"second_level_1":[{}],\
2N/A"second_level_2":[\
2N/A{"alpha":"a"},\
2N/A{"beta":"b"},\
2N/A{"gamma":"c"},\
2N/A{"delta":"d"},\
2N/A{"order":["a","b","c","d"]}\
2N/A]\
2N/A}\
2N/A]\
2N/A}
2N/AEOF)"
2N/A
2N/AOUTPUT="$(${DIR}/../../bin/print_json <<'EOF'
2N/Aadd_object "event_store";
2N/A add_string "name" "Occurences";
2N/A add_object_array "events";
2N/A add_uint32 "time" "489715200";
2N/A add_string "desc" "inception";
2N/A next;
2N/A
2N/A add_uint32 "time" "1057708800";
2N/A add_string "desc" "maturation";
2N/A next;
2N/A
2N/A add_uint32 "time" "1344816000";
2N/A add_string "desc" "migration";
2N/A next;
2N/A
2N/A add_uint32 "time" "1405296000";
2N/A add_string "desc" "integration";
2N/A next;
2N/A end;
2N/Aend;
2N/Aadd_object_array "first level";
2N/A add_object_array "second_level_0";
2N/A add_boolean "sl0_a";
2N/A add_string "sl0_b" "aaaa";
2N/A next;
2N/A add_int32 "x" "1234";
2N/A end;
2N/A add_object_array "second_level_1";
2N/A end;
2N/A add_object_array "second_level_2";
2N/A add_string "alpha" "a";
2N/A next;
2N/A add_string "beta" "b";
2N/A next;
2N/A add_string "gamma" "c";
2N/A next;
2N/A add_string "delta" "d";
2N/A next;
2N/A add_string_array "order" "a" "b" "c" "d";
2N/A end;
2N/Aend;
2N/AEOF)"
2N/A
2N/Acomplete
2N/A