Publish angle3_json_god

This commit is contained in:
thomashii 2021-05-14 20:24:45 +08:00
parent 0a15214e53
commit cfd34cbce0
21 changed files with 197 additions and 191 deletions

View file

@ -1,13 +1,32 @@
# See https://www.dartlang.org/tools/private-files.html # See https://www.dartlang.org/tools/private-files.html
# Files and directories created by pub # Files and directories created by pub
.buildlog .dart_tool
.packages .packages
.project
.pub/ .pub/
build/ build/
# If you're building an application, you may want to check-in your pubspec.lock
pubspec.lock
# Directory created by dartdoc
# If you don't generate documentation locally you can remove this line.
doc/api/
### Dart template
# See https://www.dartlang.org/tools/private-files.html
# Files and directories created by pub
# SDK 1.20 and later (no longer creates packages directories)
# Older SDK versions
# (Include if the minimum SDK version specified in pubsepc.yaml is earlier than 1.20)
.project
.buildlog
**/packages/ **/packages/
# Files created by dart2js # Files created by dart2js
# (Most Dart developers will use pub build to compile Dart, use/modify these # (Most Dart developers will use pub build to compile Dart, use/modify these
# rules if you intend to use dart2js directly # rules if you intend to use dart2js directly
@ -20,62 +39,33 @@ build/
*.info.json *.info.json
# Directory created by dartdoc # Directory created by dartdoc
doc/api/
# Don't commit pubspec lock file # Don't commit pubspec lock file
# (Library packages only! Remove pattern if developing an application package) # (Library packages only! Remove pattern if developing an application package)
pubspec.lock ### JetBrains template
.idea # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
lib/angel_client.js # User-specific stuff:
*.sum
# Logs ## VsCode
logs .vscode/
*.log
npm-debug.log*
# Runtime data ## File-based project format:
pids *.iws
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover ## Plugin-specific files:
lib-cov
# Coverage directory used by tools like istanbul # IntelliJ
coverage .idea/
/out/
.idea_modules/
# nyc test coverage # JIRA plugin
.nyc_output atlassian-ide-plugin.xml
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) # Crashlytics plugin (for Android Studio and IntelliJ)
.grunt com_crashlytics_export_strings.xml
crashlytics.properties
# node-waf configuration crashlytics-build.properties
.lock-wscript fabric.properties
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules
jspm_packages
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
.dart_tool

View file

@ -1,2 +1,12 @@
Tobe O <thosakwe@gmail.com> Primary Authors
Thomas Hii <thomashii@dukefirehawk.com> ===============
* __[Thomas Hii](dukefirehawk.apps@gmail.com)__
Thomas is the current maintainer of the code base. He has refactored and migrated the
code base to support NNBD.
* __[Tobe O](thosakwe@gmail.com)__
Tobe has written much of the original code prior to NNBD migration. He has moved on and
is no longer involved with the project.

View file

@ -1,6 +1,6 @@
The MIT License (MIT) MIT License
Copyright (c) 2016 angel-dart Copyright (c) 2021 dukefirehawk.com
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -1,44 +1,45 @@
# See https://www.dartlang.org/tools/private-files.html # See https://www.dartlang.org/tools/private-files.html
.idea
**/bower_components/
# Files and directories created by pub # Files and directories created by pub
.buildlog .dart_tool
.packages .packages
.project
.pub/ .pub/
build/ build/
**/packages/
# Files created by dart2js # If you're building an application, you may want to check-in your pubspec.lock
# (Most Dart developers will use pub build to compile Dart, use/modify these pubspec.lock
# rules if you intend to use dart2js directly
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
# differentiate from explicit Javascript files)
# *.dart.js
*.part.js
*.js.deps
# *.js.map
*.info.json
# Directory created by dartdoc # Directory created by dartdoc
doc/ # If you don't generate documentation locally you can remove this line.
doc/api/
# Don't commit pubspec lock file
# (Library packages only! Remove pattern if developing an application package)
pubspec.lock
### Dart template ### Dart template
# See https://www.dartlang.org/tools/private-files.html # See https://www.dartlang.org/tools/private-files.html
# Files and directories created by pub # Files and directories created by pub
# SDK 1.20 and later (no longer creates packages directories)
# Older SDK versions
# (Include if the minimum SDK version specified in pubsepc.yaml is earlier than 1.20)
.project
.buildlog
**/packages/
# Files created by dart2js # Files created by dart2js
# (Most Dart developers will use pub build to compile Dart, use/modify these # (Most Dart developers will use pub build to compile Dart, use/modify these
# rules if you intend to use dart2js directly # rules if you intend to use dart2js directly
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to # Convention is to use extension '.dart.js' for Dart compiled to Javascript to
# differentiate from explicit Javascript files) # differentiate from explicit Javascript files)
*.dart.js *.dart.js
*.part.js
*.js.deps
*.js.map
*.info.json
# Directory created by dartdoc # Directory created by dartdoc
# Don't commit pubspec lock file # Don't commit pubspec lock file
# (Library packages only! Remove pattern if developing an application package) # (Library packages only! Remove pattern if developing an application package)
### JetBrains template ### JetBrains template
@ -46,22 +47,9 @@ pubspec.lock
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff: # User-specific stuff:
.idea/tasks.xml
.idea/dictionaries
.idea/jsLibraryMappings.xml
# Sensitive or high-churn files: ## VsCode
.idea/dataSources.ids .vscode/
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml
# Gradle:
.idea/gradle.xml
# Mongo Explorer plugin:
.idea/mongoSettings.xml
## File-based project format: ## File-based project format:
*.iws *.iws
@ -69,9 +57,8 @@ pubspec.lock
## Plugin-specific files: ## Plugin-specific files:
# IntelliJ # IntelliJ
.idea/
/out/ /out/
# mpeltonen/sbt-idea plugin
.idea_modules/ .idea_modules/
# JIRA plugin # JIRA plugin

View file

@ -1,2 +1,12 @@
Tobe O <thosakwe@gmail.com> Primary Authors
Thomas Hii <thomashii@dukefirehawk.com> ===============
* __[Thomas Hii](dukefirehawk.apps@gmail.com)__
Thomas is the current maintainer of the code base. He has refactored and migrated the
code base to support NNBD.
* __[Tobe O](thosakwe@gmail.com)__
Tobe has written much of the original code prior to NNBD migration. He has moved on and
is no longer involved with the project.

View file

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2016 Tobe O Copyright (c) 2021 dukefirehawk.com
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -1,21 +1,23 @@
# JSON God v2 # angel3_json_god
[![version](https://img.shields.io/badge/pub-v2.12.4-brightgreen)](https://pub.dartlang.org/packages/angel3_json_god)
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/json_god/LICENSE)
[![Pub](https://img.shields.io/pub/v/json_god.svg)](https://pub.dartlang.org/packages/json_god)
[![build status](https://travis-ci.org/thosakwe/json_god.svg)](https://travis-ci.org/thosakwe/json_god)
The ***new and improved*** definitive solution for JSON in Dart. The ***new and improved*** definitive solution for JSON in Dart.
# Installation # Installation
dependencies: dependencies:
json_god: ^2.0.0-beta angel3_json_god: ^4.0.0
# Usage # Usage
It is recommended to import the library under an alias, i.e., `god`. It is recommended to import the library under an alias, i.e., `god`.
```dart ```dart
import 'package:json_god/json_god.dart' as god; import 'package:angel3_json_god/angel3_json_god.dart' as god;
``` ```
## Serializing JSON ## Serializing JSON
@ -42,13 +44,13 @@ class B {
A nested; A nested;
B(String hello, String foo) { B(String hello, String foo) {
this.hello = hello; this.hello = hello;
this.nested = new A(foo); this.nested = A(foo);
} }
} }
main() { main() {
God god = new God(); God god = God();
print(god.serialize(new B("world", "bar"))); print(god.serialize( B("world", "bar")));
} }
// Output: {"hello":"world","nested":{"foo":"bar"}} // Output: {"hello":"world","nested":{"foo":"bar"}}
@ -78,18 +80,18 @@ class Child {
class Parent { class Parent {
String hello; String hello;
Child child = new Child(); Child child = Child();
} }
main() { main() {
God god = new God(); God god = God();
Parent parent = god.deserialize('{"hello":"world","child":{"foo":"bar"}}', Parent); Parent parent = god.deserialize('{"hello":"world","child":{"foo":"bar"}}', Parent);
print(parent); print(parent);
} }
``` ```
**Any JSON-deserializable classes must initializable without parameters. **Any JSON-deserializable classes must initializable without parameters.
If `new Foo()` would throw an error, then you can't use Foo with JSON.** If ` Foo()` would throw an error, then you can't use Foo with JSON.**
This allows for validation of a sort, as only fields you have declared will be This allows for validation of a sort, as only fields you have declared will be
accepted. accepted.

View file

@ -1,5 +1,5 @@
/// A robust library for JSON serialization and deserialization. /// A robust library for JSON serialization and deserialization.
library json_god; library angel3_json_god;
//import 'package:dart2_constant/convert.dart'; //import 'package:dart2_constant/convert.dart';
import 'dart:convert'; import 'dart:convert';
@ -15,4 +15,4 @@ part 'src/util.dart';
@deprecated @deprecated
bool debug = false; bool debug = false;
final Logger logger = new Logger('json_god'); final Logger logger = Logger('json_god');

View file

@ -1,4 +1,4 @@
part of json_god; part of angel3_json_god;
/// Deserializes a JSON string into a Dart datum. /// Deserializes a JSON string into a Dart datum.
/// ///
@ -14,7 +14,8 @@ deserializeJson(String s, {Type? outputType}) {
logger.info("Deserializing the following JSON: $s"); logger.info("Deserializing the following JSON: $s");
if (outputType == null) { if (outputType == null) {
logger.info("No output type was specified, so we are just using json.decode"); logger
.info("No output type was specified, so we are just using json.decode");
return json.decode(s); return json.decode(s);
} else { } else {
logger.info("Now deserializing to type: $outputType"); logger.info("Now deserializing to type: $outputType");

View file

@ -1,7 +1,7 @@
library json_god.reflection; library angel3_json_god.reflection;
import 'dart:mirrors'; import 'dart:mirrors';
import 'package:json_god/json_god.dart'; import '../angel3_json_god.dart';
const Symbol hashCodeSymbol = #hashCode; const Symbol hashCodeSymbol = #hashCode;
const Symbol runtimeTypeSymbol = #runtimeType; const Symbol runtimeTypeSymbol = #runtimeType;
@ -76,8 +76,8 @@ deserialize(value, Type outputType, Deserializer deserializer,
} }
if (typeArguments.isEmpty) return it.toList(); if (typeArguments.isEmpty) return it.toList();
logger.info('Casting list elements to ${typeArguments[0] logger.info(
.reflectedType} via List.from'); 'Casting list elements to ${typeArguments[0].reflectedType} via List.from');
var mirror = reflectType(List, [typeArguments[0].reflectedType]); var mirror = reflectType(List, [typeArguments[0].reflectedType]);
@ -86,7 +86,7 @@ deserialize(value, Type outputType, Deserializer deserializer,
logger.info('Casted list type: ${output.runtimeType}'); logger.info('Casted list type: ${output.runtimeType}');
return output; return output;
} else { } else {
throw new ArgumentError( throw ArgumentError(
'${typeArguments[0].reflectedType} is not a class.'); '${typeArguments[0].reflectedType} is not a class.');
} }
} else if (value is Map) } else if (value is Map)
@ -107,12 +107,11 @@ _deserializeFromJsonByReflection(
var typeMirror = reflectType(outputType); var typeMirror = reflectType(outputType);
if (typeMirror is! ClassMirror) { if (typeMirror is! ClassMirror) {
throw new ArgumentError('$outputType is not a class.'); throw ArgumentError('$outputType is not a class.');
} }
var type = typeMirror; var type = typeMirror;
var fromJson = var fromJson = Symbol('${MirrorSystem.getName(type.simpleName)}.fromJson');
new Symbol('${MirrorSystem.getName(type.simpleName)}.fromJson');
for (Symbol symbol in type.declarations.keys) { for (Symbol symbol in type.declarations.keys) {
if (symbol == fromJson) { if (symbol == fromJson) {
@ -129,7 +128,7 @@ _deserializeFromJsonByReflection(
} }
ClassMirror classMirror = type; ClassMirror classMirror = type;
InstanceMirror instanceMirror = classMirror.newInstance(new Symbol(""), []); InstanceMirror instanceMirror = classMirror.newInstance(Symbol(""), []);
if (classMirror.isSubclassOf(reflectClass(Map))) { if (classMirror.isSubclassOf(reflectClass(Map))) {
var typeArguments = classMirror.typeArguments; var typeArguments = classMirror.typeArguments;
@ -143,7 +142,7 @@ _deserializeFromJsonByReflection(
reflectType(Map, typeArguments.map((t) => t.reflectedType).toList()) reflectType(Map, typeArguments.map((t) => t.reflectedType).toList())
as ClassMirror; as ClassMirror;
logger.info('Casting this map $data to Map of [$typeArguments]'); logger.info('Casting this map $data to Map of [$typeArguments]');
var output = mapType.newInstance(new Symbol(''), []).reflectee; var output = mapType.newInstance(Symbol(''), []).reflectee;
for (var key in data.keys) { for (var key in data.keys) {
output[key] = data[key]; output[key] = data[key];
@ -159,10 +158,10 @@ _deserializeFromJsonByReflection(
logger.info("data[\"$key\"] = ${data[key]}"); logger.info("data[\"$key\"] = ${data[key]}");
var deserializedValue = deserializer(data[key]); var deserializedValue = deserializer(data[key]);
logger.info("I want to set $key to the following ${deserializedValue logger.info(
.runtimeType}: $deserializedValue"); "I want to set $key to the following ${deserializedValue.runtimeType}: $deserializedValue");
// Get target type of getter // Get target type of getter
Symbol searchSymbol = new Symbol(key.toString()); Symbol searchSymbol = Symbol(key.toString());
Symbol symbolForGetter = classMirror.instanceMembers.keys Symbol symbolForGetter = classMirror.instanceMembers.keys
.firstWhere((x) => x == searchSymbol); .firstWhere((x) => x == searchSymbol);
Type requiredType = classMirror Type requiredType = classMirror
@ -176,9 +175,8 @@ _deserializeFromJsonByReflection(
} }
logger.info( logger.info(
"Final deserialized value for $key: $deserializedValue <${deserializedValue "Final deserialized value for $key: $deserializedValue <${deserializedValue.runtimeType}>");
.runtimeType}>"); instanceMirror.setField(Symbol(key.toString()), deserializedValue);
instanceMirror.setField(new Symbol(key.toString()), deserializedValue);
logger.info("Success! $key has been set to $deserializedValue"); logger.info("Success! $key has been set to $deserializedValue");
} catch (e, st) { } catch (e, st) {

View file

@ -1,4 +1,4 @@
part of json_god; part of angel3_json_god;
/// Serializes any arbitrary Dart datum to JSON. Supports schema validation. /// Serializes any arbitrary Dart datum to JSON. Supports schema validation.
String serialize(value) { String serialize(value) {

View file

@ -1,4 +1,4 @@
part of json_god; part of angel3_json_god;
bool _isPrimitive(value) { bool _isPrimitive(value) {
return value is num || value is bool || value is String || value == null; return value is num || value is bool || value is String || value == null;

View file

@ -1,4 +1,4 @@
part of json_god; part of angel3_json_god;
/// Thrown when schema validation fails. /// Thrown when schema validation fails.
class JsonValidationError implements Exception { class JsonValidationError implements Exception {
@ -7,7 +7,7 @@ class JsonValidationError implements Exception {
final String cause; final String cause;
const JsonValidationError( const JsonValidationError(
String this.cause, this.invalidData);//, Schema this.schema); String this.cause, this.invalidData); //, Schema this.schema);
} }
/// Specifies a schema to validate a class with. /// Specifies a schema to validate a class with.

View file

@ -1,7 +1,7 @@
name: json_god name: angel3_json_god
version: 4.0.0 version: 4.0.0
description: Easy JSON serialization and deserialization in Dart. description: Easy JSON serialization and deserialization in Dart.
homepage: https://github.com/thosakwe/json_god homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/json_god
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.12.0 <3.0.0'
dependencies: dependencies:
@ -9,4 +9,4 @@ dependencies:
logging: ^1.0.1 logging: ^1.0.1
dev_dependencies: dev_dependencies:
stack_trace: ^1.10.0 stack_trace: ^1.10.0
test: ^1.17.3 test: ^1.17.4

View file

@ -1,4 +1,4 @@
import 'package:json_god/json_god.dart' as god; import 'package:angel3_json_god/angel3_json_god.dart' as god;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'shared.dart'; import 'shared.dart';
@ -10,7 +10,8 @@ main() {
test('deserialize maps', testDeserializationOfMaps); test('deserialize maps', testDeserializationOfMaps);
test('deserialize maps + reflection', testDeserializationOfMapsWithReflection); test('deserialize maps + reflection',
testDeserializationOfMapsWithReflection);
test('deserialize lists + reflection', test('deserialize lists + reflection',
testDeserializationOfListsAsWellAsViaReflection); testDeserializationOfListsAsWellAsViaReflection);
@ -33,7 +34,7 @@ testDeserializationOfMaps() {
'{"hello":"world", "one": 1, "class": {"hello": "world"}}'; '{"hello":"world", "one": 1, "class": {"hello": "world"}}';
String nestedJson = String nestedJson =
'{"foo": {"bar": "baz", "funny": {"how": "life", "seems": 2, "hate": "us sometimes"}}}'; '{"foo": {"bar": "baz", "funny": {"how": "life", "seems": 2, "hate": "us sometimes"}}}';
var simple = god.deserialize(simpleJson ) as Map; var simple = god.deserialize(simpleJson) as Map;
var nested = god.deserialize(nestedJson) as Map; var nested = god.deserialize(nestedJson) as Map;
expect(simple['hello'], equals('world')); expect(simple['hello'], equals('world'));
@ -78,7 +79,8 @@ testDeserializationOfListsAsWellAsViaReflection() {
] ]
'''; ''';
var list = god.deserialize(json, outputType: (<SampleClass>[]).runtimeType) as List<SampleClass>; var list = god.deserialize(json, outputType: (<SampleClass>[]).runtimeType)
as List<SampleClass>;
SampleClass first = list[0]; SampleClass first = list[0];
SampleClass second = list[1]; SampleClass second = list[1];
@ -99,7 +101,8 @@ testDeserializationWithSchemaValidation() async {
String babelRcJson = String babelRcJson =
'{"presets":["es2015","stage-0"],"plugins":["add-module-exports"]}'; '{"presets":["es2015","stage-0"],"plugins":["add-module-exports"]}';
var deserialized = god.deserialize(babelRcJson, outputType: BabelRc) as BabelRc; var deserialized =
god.deserialize(babelRcJson, outputType: BabelRc) as BabelRc;
print(deserialized.presets.runtimeType); print(deserialized.presets.runtimeType);
expect(deserialized.presets is List, equals(true)); expect(deserialized.presets is List, equals(true));

View file

@ -1,7 +1,7 @@
//import 'package:dart2_constant/convert.dart'; //import 'package:dart2_constant/convert.dart';
import 'dart:convert'; import 'dart:convert';
import 'package:json_god/json_god.dart' as god; import 'package:angel3_json_god/angel3_json_god.dart' as god;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'shared.dart'; import 'shared.dart';
@ -33,7 +33,7 @@ testSerializationOfPrimitives() {
} }
testSerializationOfDates() { testSerializationOfDates() {
DateTime date = new DateTime.now(); DateTime date = DateTime.now();
String s = god.serialize({'date': date}); String s = god.serialize({'date': date});
print(s); print(s);
@ -43,8 +43,8 @@ testSerializationOfDates() {
} }
testSerializationOfMaps() { testSerializationOfMaps() {
var simple = json.decode(god.serialize( var simple = json.decode(god
{'hello': 'world', 'one': 1, 'class': new SampleClass('world')})); .serialize({'hello': 'world', 'one': 1, 'class': SampleClass('world')}));
var nested = json.decode(god.serialize({ var nested = json.decode(god.serialize({
'foo': { 'foo': {
'bar': 'baz', 'bar': 'baz',
@ -66,8 +66,8 @@ testSerializationOfLists() {
List pandorasBox = [ List pandorasBox = [
1, 1,
"2", "2",
{"num": 3, "four": new SampleClass('five')}, {"num": 3, "four": SampleClass('five')},
new SampleClass('six')..nested.add(new SampleNestedClass('seven')) SampleClass('six')..nested.add(SampleNestedClass('seven'))
]; ];
String s = god.serialize(pandorasBox); String s = god.serialize(pandorasBox);
print(s); print(s);
@ -91,10 +91,10 @@ testSerializationOfLists() {
} }
testSerializationViaReflection() { testSerializationViaReflection() {
SampleClass sample = new SampleClass('world'); SampleClass sample = SampleClass('world');
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
sample.nested.add(new SampleNestedClass('baz')); sample.nested.add(SampleNestedClass('baz'));
} }
String s = god.serialize(sample); String s = god.serialize(sample);
@ -110,8 +110,8 @@ testSerializationViaReflection() {
} }
testSerializationWithSchemaValidation() async { testSerializationWithSchemaValidation() async {
BabelRc babelRc = new BabelRc( BabelRc babelRc =
presets: ['es2015', 'stage-0'], plugins: ['add-module-exports']); BabelRc(presets: ['es2015', 'stage-0'], plugins: ['add-module-exports']);
String s = god.serialize(babelRc); String s = god.serialize(babelRc);
print(s); print(s);

View file

@ -1,11 +1,11 @@
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:json_god/json_god.dart'; import 'package:angel3_json_god/angel3_json_god.dart';
import 'package:stack_trace/stack_trace.dart'; import 'package:stack_trace/stack_trace.dart';
void printRecord(LogRecord rec) { void printRecord(LogRecord rec) {
print(rec); print(rec);
if (rec.error != null) print(rec.error); if (rec.error != null) print(rec.error);
if (rec.stackTrace != null) print(new Chain.forTrace(rec.stackTrace!).terse); if (rec.stackTrace != null) print(Chain.forTrace(rec.stackTrace!).terse);
} }
class SampleNestedClass { class SampleNestedClass {

View file

@ -1,4 +1,4 @@
import 'package:json_god/json_god.dart' as god; import 'package:angel3_json_god/angel3_json_god.dart' as god;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'shared.dart'; import 'shared.dart';
@ -13,7 +13,7 @@ main() {
}); });
test('toJson', () { test('toJson', () {
var foo = new Foo(text: 'baz'); var foo = Foo(text: 'baz');
var data = god.serializeObject(foo); var data = god.serializeObject(foo);
expect(data, equals({'bar': 'baz', 'foo': 'poobaz'})); expect(data, equals({'bar': 'baz', 'foo': 'poobaz'}));
}); });
@ -26,7 +26,7 @@ class Foo {
Foo({this.text}); Foo({this.text});
factory Foo.fromJson(Map json) => new Foo(text: json['bar'].toString()); factory Foo.fromJson(Map json) => Foo(text: json['bar'].toString());
Map toJson() => {'bar': text, 'foo': foo}; Map toJson() => {'bar': text, 'foo': foo};
} }

View file

@ -1,12 +1,31 @@
# See https://www.dartlang.org/tools/private-files.html # See https://www.dartlang.org/tools/private-files.html
# Files and directories created by pub # Files and directories created by pub
.buildlog .dart_tool
.packages .packages
.project
.pub/ .pub/
build/ build/
#**/packages/
# If you're building an application, you may want to check-in your pubspec.lock
pubspec.lock
# Directory created by dartdoc
# If you don't generate documentation locally you can remove this line.
doc/api/
### Dart template
# See https://www.dartlang.org/tools/private-files.html
# Files and directories created by pub
# SDK 1.20 and later (no longer creates packages directories)
# Older SDK versions
# (Include if the minimum SDK version specified in pubsepc.yaml is earlier than 1.20)
.project
.buildlog
**/packages/
# Files created by dart2js # Files created by dart2js
# (Most Dart developers will use pub build to compile Dart, use/modify these # (Most Dart developers will use pub build to compile Dart, use/modify these
@ -20,38 +39,17 @@ build/
*.info.json *.info.json
# Directory created by dartdoc # Directory created by dartdoc
doc/api/
# Don't commit pubspec lock file # Don't commit pubspec lock file
# (Library packages only! Remove pattern if developing an application package) # (Library packages only! Remove pattern if developing an application package)
pubspec.lock
.idea
log.txt
### JetBrains template ### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff: # User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files: ## VsCode
.idea/**/dataSources/ .vscode/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format: ## File-based project format:
*.iws *.iws
@ -59,9 +57,8 @@ log.txt
## Plugin-specific files: ## Plugin-specific files:
# IntelliJ # IntelliJ
.idea/
/out/ /out/
# mpeltonen/sbt-idea plugin
.idea_modules/ .idea_modules/
# JIRA plugin # JIRA plugin
@ -72,5 +69,3 @@ com_crashlytics_export_strings.xml
crashlytics.properties crashlytics.properties
crashlytics-build.properties crashlytics-build.properties
fabric.properties fabric.properties
.dart_tool

View file

@ -1,2 +1,12 @@
Tobe O <thosakwe@gmail.com> Primary Authors
Thomas Hii <thomashii@dukefirehawk.com> ===============
* __[Thomas Hii](dukefirehawk.apps@gmail.com)__
Thomas is the current maintainer of the code base. He has refactored and migrated the
code base to support NNBD.
* __[Tobe O](thosakwe@gmail.com)__
Tobe has written much of the original code prior to NNBD migration. He has moved on and
is no longer involved with the project.

View file

@ -1,6 +1,6 @@
The MIT License (MIT) MIT License
Copyright (c) 2016 angel-dart Copyright (c) 2021 dukefirehawk.com
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal