Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
aristosh committed Oct 27, 2021
1 parent 7190a5c commit dca92c9
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'package:lazy_json/lazy_json.dart';

void main() {
final jsonObject = {
'response': {
'data': {'id': '001', 'label': 'Hello', 'number': 10}
}
};

print(jsonObject
.object('response')
.object('data')
.string('label', 'default value')); // prints 'Hello'

print(jsonObject
.object('response')
.object('data')
.string('dummyField', 'default value')); // prints 'default value'

print(jsonObject
.object('response')
.object('data')
.integer('number')); // prints 10

print(jsonObject
.object('response')
.object('data')
.integer('dummyField', 99)); // prints 10
}

0 comments on commit dca92c9

Please sign in to comment.