 |
Changeset 3875
- Timestamp:
- 08/11/08 16:36:02
(4 months ago)
- Author:
- kris
- Message:
added a bit of doc
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3872 |
r3875 |
|
| 20 | 20 | private import Float = tango.text.convert.Float; |
|---|
| 21 | 21 | |
|---|
| 22 | | |
|---|
| 23 | | |
|---|
| 24 | | /** |
|---|
| 25 | | * Enumerates the seven acceptable JSON value types. |
|---|
| 26 | | */ |
|---|
| 27 | | /** |
|---|
| 28 | | * Represents a JSON value that is one of the seven types specified by the enum |
|---|
| 29 | | * Type. |
|---|
| 30 | | */ |
|---|
| 31 | | /** |
|---|
| 32 | | * Represents a single JSON Object. |
|---|
| 33 | | */ |
|---|
| 34 | | |
|---|
| 35 | 22 | /******************************************************************************* |
|---|
| | 23 | |
|---|
| | 24 | Parse JSON text into a set of inter-related structures. Typical usage |
|---|
| | 25 | is as follows: |
|---|
| | 26 | --- |
|---|
| | 27 | auto p = new Json!(char); |
|---|
| | 28 | auto v = p.parse (`{"t": true, "n":null, "array":["world", [4, 5]]}`); |
|---|
| | 29 | --- |
|---|
| | 30 | |
|---|
| | 31 | Converting back to text format employs a delegate: |
|---|
| | 32 | --- |
|---|
| | 33 | v.print ((char[] s) {Stdout(s);}); |
|---|
| | 34 | --- |
|---|
| 36 | 35 | |
|---|
| 37 | 36 | *******************************************************************************/ |
|---|
| … | … | |
| 39 | 38 | class Json(T) : private JsonParser!(T) |
|---|
| 40 | 39 | { |
|---|
| | 40 | /// use these types for external references |
|---|
| 41 | 41 | public alias JsonValue* Value; |
|---|
| 42 | 42 | public alias NameValue* Attribute; |
|---|
| 43 | 43 | public alias JsonObject* Composite; |
|---|
| 44 | 44 | |
|---|
| | 45 | /// enumerates the seven acceptable JSON value types |
|---|
| 45 | 46 | public enum Type {Null, String, RawString, Number, Object, Array, True, False}; |
|---|
| 46 | 47 | |
|---|
| 47 | 48 | /*********************************************************************** |
|---|
| 48 | 49 | |
|---|
| | 50 | Construct a json instance |
|---|
| | 51 | |
|---|
| 49 | 52 | ***********************************************************************/ |
|---|
| 50 | 53 | |
|---|
| … | … | |
| 56 | 59 | /*********************************************************************** |
|---|
| 57 | 60 | |
|---|
| | 61 | Parse the given text and return a resultant Value type |
|---|
| | 62 | |
|---|
| 58 | 63 | ***********************************************************************/ |
|---|
| 59 | 64 | |
|---|
| 60 | 65 | public Value parse (T[] json) |
|---|
| 61 | 66 | { |
|---|
| 62 | | |
|---|
| 63 | 67 | nesting = 0; |
|---|
| 64 | 68 | attrib.reset; |
|---|
| … | … | |
| 327 | 331 | |
|---|
| 328 | 332 | /*********************************************************************** |
|---|
| 329 | | |
|---|
| | 333 | |
|---|
| | 334 | Represents a single json Object |
|---|
| | 335 | |
|---|
| 330 | 336 | ***********************************************************************/ |
|---|
| 331 | 337 | |
|---|
| … | … | |
| 420 | 426 | /*********************************************************************** |
|---|
| 421 | 427 | |
|---|
| | 428 | Represents a json value that is one of the seven types |
|---|
| | 429 | specified via the Json.Type enum |
|---|
| | 430 | |
|---|
| 422 | 431 | ***********************************************************************/ |
|---|
| 423 | 432 | |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic