|
| 1 | +/////// |
| 2 | +// These values taken from https://amazon-ion.github.io/ion-docs/docs/spec.html |
| 3 | +////// |
| 4 | + |
| 5 | + |
| 6 | +null |
| 7 | + |
| 8 | +nan |
| 9 | +-inf |
| 10 | ++inf |
| 11 | + |
| 12 | +null.null // Identical to unadorned null |
| 13 | +null.bool |
| 14 | +null.int |
| 15 | +null.float |
| 16 | +null.decimal |
| 17 | +null.timestamp |
| 18 | +null.string |
| 19 | +null.symbol |
| 20 | +null.blob |
| 21 | +null.clob |
| 22 | +null.struct |
| 23 | +null.list |
| 24 | +null.sexp |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +null // The type is null |
| 29 | +'null' // The type is symbol |
| 30 | +null.list // The type is list |
| 31 | +'null.int' // The type is symbol |
| 32 | + |
| 33 | + |
| 34 | +null.bool |
| 35 | +true |
| 36 | +false |
| 37 | + |
| 38 | + |
| 39 | +null.int // A null int value |
| 40 | +0 // Zero. Surprise! |
| 41 | +-0 // ...the same value with a minus sign |
| 42 | +123 // A normal int |
| 43 | +-123 // Another negative int |
| 44 | +0xBeef // An int denoted in hexadecimal |
| 45 | +0b0101 // An int denoted in binary |
| 46 | +1_2_3 // An int with underscores |
| 47 | +0xFA_CE // An int denoted in hexadecimal with underscores |
| 48 | +0b10_10_10 // An int denoted in binary with underscores |
| 49 | + |
| 50 | +_1 // A symbol (ints cannot start with underscores) |
| 51 | + |
| 52 | + |
| 53 | +null.decimal // A null decimal value |
| 54 | +null.float // A null float value |
| 55 | + |
| 56 | +0.123 // Type is decimal |
| 57 | +-0.12e4 // Type is float |
| 58 | +-0.12d4 // Type is decimal |
| 59 | + |
| 60 | +0E0 // Zero as float |
| 61 | +0D0 // Zero as decimal |
| 62 | +0. // ...the same decimal value with different notation |
| 63 | +-0e0 // Negative zero float (distinct from positive zero) |
| 64 | +-0d0 // Negative zero decimal (distinct from positive zero) |
| 65 | +-0. // ...the same decimal value with different notation |
| 66 | +-0d-1 // Decimal maintains precision: -0. != -0.0 |
| 67 | + |
| 68 | +123_456.789_012 // Decimal with underscores |
| 69 | + |
| 70 | + |
| 71 | +null.timestamp // A null timestamp value |
| 72 | + |
| 73 | +2007-02-23T12:14Z // Seconds are optional, but local offset is not |
| 74 | +2007-02-23T12:14:33.079-08:00 // A timestamp with millisecond precision and PST local time |
| 75 | +2007-02-23T20:14:33.079Z // The same instant in UTC ("zero" or "zulu") |
| 76 | +2007-02-23T20:14:33.079+00:00 // The same instant, with explicit local offset |
| 77 | +2007-02-23T20:14:33.079-00:00 // The same instant, with unknown local offset |
| 78 | + |
| 79 | +2007-01-01T00:00-00:00 // Happy New Year in UTC, unknown local offset |
| 80 | +2007-01-01 // The same instant, with days precision, unknown local offset |
| 81 | +2007-01-01T // The same value, different syntax. |
| 82 | +2007-01T // The same instant, with months precision, unknown local offset |
| 83 | +2007T // The same instant, with years precision, unknown local offset |
| 84 | + |
| 85 | +2007-02-23 // A day, unknown local offset |
| 86 | +2007-02-23T00:00Z // The same instant, but more precise and in UTC |
| 87 | +2007-02-23T00:00+00:00 // An equivalent format for the same value |
| 88 | +2007-02-23T00:00:00-00:00 // The same instant, with seconds precision |
| 89 | + |
| 90 | +2007 // Not a timestamp, but an int |
| 91 | + |
| 92 | +2000T // January 1st 2000, year precision, unknown local offset |
| 93 | +2000-01-01T00:00:00Z // January 1st 2000, second precision, UTC |
| 94 | +2000-01-01T00:00:00.000Z // January 1st 2000, millisecond precision, UTC |
| 95 | +2000-01-01T00:00:00.000-00:00 // January 1st 2000, millisecond precision, negative zero local offset |
| 96 | + |
| 97 | + |
| 98 | +null.string // A null string value |
| 99 | +"" // An empty string value |
| 100 | +" my string " // A normal string |
| 101 | +"\"" // Contains one double-quote character |
| 102 | +"\uABCD" // Contains one unicode character |
| 103 | + |
| 104 | +xml::"<e a='v'>c</e>" // String with type annotation 'xml' |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | +( '''hello ''' // Sexp with one element |
| 110 | + '''world!''' ) |
| 111 | + |
| 112 | +("hello world!") // The exact same sexp value |
| 113 | + |
| 114 | +// This Ion value is a string containing three newlines. The serialized |
| 115 | +// form's first newline is escaped into nothingness. |
| 116 | +'''\ |
| 117 | +The first line of the string. |
| 118 | +This is the second line of the string, |
| 119 | +and this is the third line. |
| 120 | +''' |
| 121 | + |
| 122 | + |
| 123 | +null.symbol // A null symbol value |
| 124 | +'myVar2' // A symbol |
| 125 | +myVar2 // The same symbol |
| 126 | +myvar2 // A different symbol |
| 127 | +'hi ho' // Symbol requiring quotes |
| 128 | +'\'ahoy\'' // A symbol with embedded quotes |
| 129 | +'' // The empty symbol |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | +( 'x' '+' 'y' ) // S-expression with three symbols |
| 135 | +( x + y ) // The same three symbols |
| 136 | +(x+y) // The same three symbols |
| 137 | +(a==b&&c==d) // S-expression with seven symbols |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | + |
| 142 | +// A null blob value |
| 143 | +null.blob |
| 144 | + |
| 145 | +// A valid blob value with zero padding characters. |
| 146 | +{{ |
| 147 | + +AB/ |
| 148 | +}} |
| 149 | + |
| 150 | +// A valid blob value with one required padding character. |
| 151 | +{{ VG8gaW5maW5pdHkuLi4gYW5kIGJleW9uZCE= }} |
| 152 | + |
| 153 | +// A valid blob value with two required padding characters. |
| 154 | +{{ dHdvIHBhZGRpbmcgY2hhcmFjdGVycw== }} |
| 155 | + |
| 156 | + |
| 157 | + |
| 158 | + |
| 159 | +null.clob // A null clob value |
| 160 | + |
| 161 | +{{ "This is a CLOB of text." }} |
| 162 | + |
| 163 | +shift_jis :: |
| 164 | +{{ |
| 165 | + '''Another clob with user-defined encoding, ''' |
| 166 | + '''this time on multiple lines.''' |
| 167 | +}} |
| 168 | + |
| 169 | + |
| 170 | + |
| 171 | + |
| 172 | +null.struct // A null struct value |
| 173 | +{ } // An empty struct value |
| 174 | +{ first : "Tom" , last: "Riddle" } // Structure with two fields |
| 175 | +{"first":"Tom","last":"Riddle"} // The same value with confusing style |
| 176 | +{center:{x:1.0, y:12.5}, radius:3} // Nested struct |
| 177 | +{ x:1, } // Trailing comma is legal in Ion (unlike JSON) |
| 178 | +{ "":42 } // A struct value containing a field with an empty name |
| 179 | +{ x:1, x:null.int } // WARNING: repeated name 'x' leads to undefined behavior |
| 180 | + |
| 181 | + |
| 182 | + |
| 183 | +{ field_name: annotation:: value } // Okay |
| 184 | + |
| 185 | + |
| 186 | + |
| 187 | + |
| 188 | + |
| 189 | +null.list // A null list value |
| 190 | +[] // An empty list value |
| 191 | +[1, 2, 3] // List of three ints |
| 192 | +[ 1 , two ] // List of an int and a symbol |
| 193 | +[a , [b]] // Nested list |
| 194 | +[ 1.2, ] // Trailing comma is legal in Ion (unlike JSON) |
| 195 | + |
| 196 | + |
| 197 | +null.sexp // A null S-expression value |
| 198 | +() // An empty expression value |
| 199 | +(cons 1 2) // S-expression of three values |
| 200 | +([hello][there]) // S-expression containing two lists |
| 201 | + |
| 202 | +(a+-b) ( 'a' '+-' 'b' ) // Equivalent; three symbols |
| 203 | +(a.b;) ( 'a' '.' 'b' ';') // Equivalent; four symbols |
| 204 | + |
| 205 | + |
| 206 | +(a/* word */b) // An S-expression with two symbols and a comment |
| 207 | +(a '/*' word '*/' b) // An S-expression with five symbols |
| 208 | + |
| 209 | + |
| 210 | + |
| 211 | + |
| 212 | + |
| 213 | +int32::12 // Suggests 32 bits as end-user type |
| 214 | +degrees::'celsius'::100 // You can have multiple annotaions on a value |
| 215 | +'my.custom.type' :: { x : 12 , y : -1 } // Gives a struct a user-defined type |
| 216 | + |
| 217 | +{ field: some_annotation::value } // Field's name must precede annotations of its value |
| 218 | + |
| 219 | +bool :: null.int // A very misleading annotation on the integer null |
| 220 | +'' :: 1 // An empty annotation |
| 221 | + |
0 commit comments