Publish angle3_json_god
This commit is contained in:
parent
0a15214e53
commit
cfd34cbce0
21 changed files with 197 additions and 191 deletions
96
packages/client/.gitignore
vendored
96
packages/client/.gitignore
vendored
|
@ -1,15 +1,34 @@
|
|||
# See https://www.dartlang.org/tools/private-files.html
|
||||
|
||||
# Files and directories created by pub
|
||||
.buildlog
|
||||
.dart_tool
|
||||
.packages
|
||||
.project
|
||||
.pub/
|
||||
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/
|
||||
|
||||
|
||||
# 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
|
||||
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
|
||||
# differentiate from explicit Javascript files)
|
||||
|
@ -20,62 +39,33 @@ build/
|
|||
*.info.json
|
||||
|
||||
# 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)
|
||||
pubspec.lock
|
||||
.idea
|
||||
### JetBrains template
|
||||
# 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
|
||||
*.sum
|
||||
# User-specific stuff:
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
## VsCode
|
||||
.vscode/
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
## File-based project format:
|
||||
*.iws
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
## Plugin-specific files:
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
# IntelliJ
|
||||
.idea/
|
||||
/out/
|
||||
.idea_modules/
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# 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
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
Tobe O <thosakwe@gmail.com>
|
||||
Thomas Hii <thomashii@dukefirehawk.com>
|
||||
Primary Authors
|
||||
===============
|
||||
|
||||
* __[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.
|
||||
|
|
|
@ -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
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
59
packages/json_god/.gitignore
vendored
59
packages/json_god/.gitignore
vendored
|
@ -1,44 +1,45 @@
|
|||
# See https://www.dartlang.org/tools/private-files.html
|
||||
.idea
|
||||
**/bower_components/
|
||||
|
||||
# Files and directories created by pub
|
||||
.buildlog
|
||||
.dart_tool
|
||||
.packages
|
||||
.project
|
||||
.pub/
|
||||
build/
|
||||
**/packages/
|
||||
|
||||
# Files created by dart2js
|
||||
# (Most Dart developers will use pub build to compile Dart, use/modify these
|
||||
# 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
|
||||
# If you're building an application, you may want to check-in your pubspec.lock
|
||||
pubspec.lock
|
||||
|
||||
# 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
|
||||
# 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
|
||||
# (Most Dart developers will use pub build to compile Dart, use/modify these
|
||||
# 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
|
||||
|
||||
# Don't commit pubspec lock file
|
||||
# (Library packages only! Remove pattern if developing an application package)
|
||||
### JetBrains template
|
||||
|
@ -46,22 +47,9 @@ pubspec.lock
|
|||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff:
|
||||
.idea/tasks.xml
|
||||
.idea/dictionaries
|
||||
.idea/jsLibraryMappings.xml
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
.idea/dataSources.ids
|
||||
.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
|
||||
## VsCode
|
||||
.vscode/
|
||||
|
||||
## File-based project format:
|
||||
*.iws
|
||||
|
@ -69,9 +57,8 @@ pubspec.lock
|
|||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
.idea/
|
||||
/out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
Tobe O <thosakwe@gmail.com>
|
||||
Thomas Hii <thomashii@dukefirehawk.com>
|
||||
Primary Authors
|
||||
===============
|
||||
|
||||
* __[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.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
||||
# Installation
|
||||
dependencies:
|
||||
json_god: ^2.0.0-beta
|
||||
angel3_json_god: ^4.0.0
|
||||
|
||||
# Usage
|
||||
|
||||
It is recommended to import the library under an alias, i.e., `god`.
|
||||
|
||||
```dart
|
||||
import 'package:json_god/json_god.dart' as god;
|
||||
import 'package:angel3_json_god/angel3_json_god.dart' as god;
|
||||
```
|
||||
|
||||
## Serializing JSON
|
||||
|
@ -42,13 +44,13 @@ class B {
|
|||
A nested;
|
||||
B(String hello, String foo) {
|
||||
this.hello = hello;
|
||||
this.nested = new A(foo);
|
||||
this.nested = A(foo);
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
God god = new God();
|
||||
print(god.serialize(new B("world", "bar")));
|
||||
God god = God();
|
||||
print(god.serialize( B("world", "bar")));
|
||||
}
|
||||
|
||||
// Output: {"hello":"world","nested":{"foo":"bar"}}
|
||||
|
@ -78,18 +80,18 @@ class Child {
|
|||
|
||||
class Parent {
|
||||
String hello;
|
||||
Child child = new Child();
|
||||
Child child = Child();
|
||||
}
|
||||
|
||||
main() {
|
||||
God god = new God();
|
||||
God god = God();
|
||||
Parent parent = god.deserialize('{"hello":"world","child":{"foo":"bar"}}', Parent);
|
||||
print(parent);
|
||||
}
|
||||
```
|
||||
|
||||
**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
|
||||
accepted.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/// A robust library for JSON serialization and deserialization.
|
||||
library json_god;
|
||||
library angel3_json_god;
|
||||
|
||||
//import 'package:dart2_constant/convert.dart';
|
||||
import 'dart:convert';
|
||||
|
@ -15,4 +15,4 @@ part 'src/util.dart';
|
|||
@deprecated
|
||||
bool debug = false;
|
||||
|
||||
final Logger logger = new Logger('json_god');
|
||||
final Logger logger = Logger('json_god');
|
|
@ -1,4 +1,4 @@
|
|||
part of json_god;
|
||||
part of angel3_json_god;
|
||||
|
||||
/// Deserializes a JSON string into a Dart datum.
|
||||
///
|
||||
|
@ -14,7 +14,8 @@ deserializeJson(String s, {Type? outputType}) {
|
|||
logger.info("Deserializing the following JSON: $s");
|
||||
|
||||
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);
|
||||
} else {
|
||||
logger.info("Now deserializing to type: $outputType");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
library json_god.reflection;
|
||||
library angel3_json_god.reflection;
|
||||
|
||||
import 'dart:mirrors';
|
||||
import 'package:json_god/json_god.dart';
|
||||
import '../angel3_json_god.dart';
|
||||
|
||||
const Symbol hashCodeSymbol = #hashCode;
|
||||
const Symbol runtimeTypeSymbol = #runtimeType;
|
||||
|
@ -76,8 +76,8 @@ deserialize(value, Type outputType, Deserializer deserializer,
|
|||
}
|
||||
|
||||
if (typeArguments.isEmpty) return it.toList();
|
||||
logger.info('Casting list elements to ${typeArguments[0]
|
||||
.reflectedType} via List.from');
|
||||
logger.info(
|
||||
'Casting list elements to ${typeArguments[0].reflectedType} via List.from');
|
||||
|
||||
var mirror = reflectType(List, [typeArguments[0].reflectedType]);
|
||||
|
||||
|
@ -86,7 +86,7 @@ deserialize(value, Type outputType, Deserializer deserializer,
|
|||
logger.info('Casted list type: ${output.runtimeType}');
|
||||
return output;
|
||||
} else {
|
||||
throw new ArgumentError(
|
||||
throw ArgumentError(
|
||||
'${typeArguments[0].reflectedType} is not a class.');
|
||||
}
|
||||
} else if (value is Map)
|
||||
|
@ -107,12 +107,11 @@ _deserializeFromJsonByReflection(
|
|||
var typeMirror = reflectType(outputType);
|
||||
|
||||
if (typeMirror is! ClassMirror) {
|
||||
throw new ArgumentError('$outputType is not a class.');
|
||||
throw ArgumentError('$outputType is not a class.');
|
||||
}
|
||||
|
||||
var type = typeMirror;
|
||||
var fromJson =
|
||||
new Symbol('${MirrorSystem.getName(type.simpleName)}.fromJson');
|
||||
var fromJson = Symbol('${MirrorSystem.getName(type.simpleName)}.fromJson');
|
||||
|
||||
for (Symbol symbol in type.declarations.keys) {
|
||||
if (symbol == fromJson) {
|
||||
|
@ -129,7 +128,7 @@ _deserializeFromJsonByReflection(
|
|||
}
|
||||
|
||||
ClassMirror classMirror = type;
|
||||
InstanceMirror instanceMirror = classMirror.newInstance(new Symbol(""), []);
|
||||
InstanceMirror instanceMirror = classMirror.newInstance(Symbol(""), []);
|
||||
|
||||
if (classMirror.isSubclassOf(reflectClass(Map))) {
|
||||
var typeArguments = classMirror.typeArguments;
|
||||
|
@ -143,7 +142,7 @@ _deserializeFromJsonByReflection(
|
|||
reflectType(Map, typeArguments.map((t) => t.reflectedType).toList())
|
||||
as ClassMirror;
|
||||
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) {
|
||||
output[key] = data[key];
|
||||
|
@ -159,10 +158,10 @@ _deserializeFromJsonByReflection(
|
|||
logger.info("data[\"$key\"] = ${data[key]}");
|
||||
var deserializedValue = deserializer(data[key]);
|
||||
|
||||
logger.info("I want to set $key to the following ${deserializedValue
|
||||
.runtimeType}: $deserializedValue");
|
||||
logger.info(
|
||||
"I want to set $key to the following ${deserializedValue.runtimeType}: $deserializedValue");
|
||||
// Get target type of getter
|
||||
Symbol searchSymbol = new Symbol(key.toString());
|
||||
Symbol searchSymbol = Symbol(key.toString());
|
||||
Symbol symbolForGetter = classMirror.instanceMembers.keys
|
||||
.firstWhere((x) => x == searchSymbol);
|
||||
Type requiredType = classMirror
|
||||
|
@ -176,9 +175,8 @@ _deserializeFromJsonByReflection(
|
|||
}
|
||||
|
||||
logger.info(
|
||||
"Final deserialized value for $key: $deserializedValue <${deserializedValue
|
||||
.runtimeType}>");
|
||||
instanceMirror.setField(new Symbol(key.toString()), deserializedValue);
|
||||
"Final deserialized value for $key: $deserializedValue <${deserializedValue.runtimeType}>");
|
||||
instanceMirror.setField(Symbol(key.toString()), deserializedValue);
|
||||
|
||||
logger.info("Success! $key has been set to $deserializedValue");
|
||||
} catch (e, st) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
part of json_god;
|
||||
part of angel3_json_god;
|
||||
|
||||
/// Serializes any arbitrary Dart datum to JSON. Supports schema validation.
|
||||
String serialize(value) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
part of json_god;
|
||||
part of angel3_json_god;
|
||||
|
||||
bool _isPrimitive(value) {
|
||||
return value is num || value is bool || value is String || value == null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
part of json_god;
|
||||
part of angel3_json_god;
|
||||
|
||||
/// Thrown when schema validation fails.
|
||||
class JsonValidationError implements Exception {
|
||||
|
@ -7,7 +7,7 @@ class JsonValidationError implements Exception {
|
|||
final String cause;
|
||||
|
||||
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.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
name: json_god
|
||||
name: angel3_json_god
|
||||
version: 4.0.0
|
||||
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:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
dependencies:
|
||||
|
@ -9,4 +9,4 @@ dependencies:
|
|||
logging: ^1.0.1
|
||||
dev_dependencies:
|
||||
stack_trace: ^1.10.0
|
||||
test: ^1.17.3
|
||||
test: ^1.17.4
|
|
@ -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 'shared.dart';
|
||||
|
||||
|
@ -10,7 +10,8 @@ main() {
|
|||
|
||||
test('deserialize maps', testDeserializationOfMaps);
|
||||
|
||||
test('deserialize maps + reflection', testDeserializationOfMapsWithReflection);
|
||||
test('deserialize maps + reflection',
|
||||
testDeserializationOfMapsWithReflection);
|
||||
|
||||
test('deserialize lists + reflection',
|
||||
testDeserializationOfListsAsWellAsViaReflection);
|
||||
|
@ -33,7 +34,7 @@ testDeserializationOfMaps() {
|
|||
'{"hello":"world", "one": 1, "class": {"hello": "world"}}';
|
||||
String nestedJson =
|
||||
'{"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;
|
||||
|
||||
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 second = list[1];
|
||||
|
||||
|
@ -99,7 +101,8 @@ testDeserializationWithSchemaValidation() async {
|
|||
String babelRcJson =
|
||||
'{"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);
|
||||
expect(deserialized.presets is List, equals(true));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//import 'package:dart2_constant/convert.dart';
|
||||
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 'shared.dart';
|
||||
|
||||
|
@ -33,7 +33,7 @@ testSerializationOfPrimitives() {
|
|||
}
|
||||
|
||||
testSerializationOfDates() {
|
||||
DateTime date = new DateTime.now();
|
||||
DateTime date = DateTime.now();
|
||||
String s = god.serialize({'date': date});
|
||||
|
||||
print(s);
|
||||
|
@ -43,8 +43,8 @@ testSerializationOfDates() {
|
|||
}
|
||||
|
||||
testSerializationOfMaps() {
|
||||
var simple = json.decode(god.serialize(
|
||||
{'hello': 'world', 'one': 1, 'class': new SampleClass('world')}));
|
||||
var simple = json.decode(god
|
||||
.serialize({'hello': 'world', 'one': 1, 'class': SampleClass('world')}));
|
||||
var nested = json.decode(god.serialize({
|
||||
'foo': {
|
||||
'bar': 'baz',
|
||||
|
@ -66,8 +66,8 @@ testSerializationOfLists() {
|
|||
List pandorasBox = [
|
||||
1,
|
||||
"2",
|
||||
{"num": 3, "four": new SampleClass('five')},
|
||||
new SampleClass('six')..nested.add(new SampleNestedClass('seven'))
|
||||
{"num": 3, "four": SampleClass('five')},
|
||||
SampleClass('six')..nested.add(SampleNestedClass('seven'))
|
||||
];
|
||||
String s = god.serialize(pandorasBox);
|
||||
print(s);
|
||||
|
@ -91,10 +91,10 @@ testSerializationOfLists() {
|
|||
}
|
||||
|
||||
testSerializationViaReflection() {
|
||||
SampleClass sample = new SampleClass('world');
|
||||
SampleClass sample = SampleClass('world');
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
sample.nested.add(new SampleNestedClass('baz'));
|
||||
sample.nested.add(SampleNestedClass('baz'));
|
||||
}
|
||||
|
||||
String s = god.serialize(sample);
|
||||
|
@ -110,8 +110,8 @@ testSerializationViaReflection() {
|
|||
}
|
||||
|
||||
testSerializationWithSchemaValidation() async {
|
||||
BabelRc babelRc = new BabelRc(
|
||||
presets: ['es2015', 'stage-0'], plugins: ['add-module-exports']);
|
||||
BabelRc babelRc =
|
||||
BabelRc(presets: ['es2015', 'stage-0'], plugins: ['add-module-exports']);
|
||||
|
||||
String s = god.serialize(babelRc);
|
||||
print(s);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
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';
|
||||
|
||||
void printRecord(LogRecord rec) {
|
||||
print(rec);
|
||||
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 {
|
||||
|
|
|
@ -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 'shared.dart';
|
||||
|
||||
|
@ -13,7 +13,7 @@ main() {
|
|||
});
|
||||
|
||||
test('toJson', () {
|
||||
var foo = new Foo(text: 'baz');
|
||||
var foo = Foo(text: 'baz');
|
||||
var data = god.serializeObject(foo);
|
||||
expect(data, equals({'bar': 'baz', 'foo': 'poobaz'}));
|
||||
});
|
||||
|
@ -26,7 +26,7 @@ class Foo {
|
|||
|
||||
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};
|
||||
}
|
||||
|
|
59
packages/websocket/.gitignore
vendored
59
packages/websocket/.gitignore
vendored
|
@ -1,15 +1,34 @@
|
|||
# See https://www.dartlang.org/tools/private-files.html
|
||||
|
||||
# Files and directories created by pub
|
||||
.buildlog
|
||||
.dart_tool
|
||||
.packages
|
||||
.project
|
||||
.pub/
|
||||
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
|
||||
# (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
|
||||
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
|
||||
# differentiate from explicit Javascript files)
|
||||
|
@ -20,38 +39,17 @@ build/
|
|||
*.info.json
|
||||
|
||||
# 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)
|
||||
pubspec.lock
|
||||
.idea
|
||||
|
||||
log.txt
|
||||
### JetBrains template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff:
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/dictionaries
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
.idea/**/dataSources/
|
||||
.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
|
||||
## VsCode
|
||||
.vscode/
|
||||
|
||||
## File-based project format:
|
||||
*.iws
|
||||
|
@ -59,9 +57,8 @@ log.txt
|
|||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
.idea/
|
||||
/out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
|
@ -72,5 +69,3 @@ com_crashlytics_export_strings.xml
|
|||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
.dart_tool
|
|
@ -1,2 +1,12 @@
|
|||
Tobe O <thosakwe@gmail.com>
|
||||
Thomas Hii <thomashii@dukefirehawk.com>
|
||||
Primary Authors
|
||||
===============
|
||||
|
||||
* __[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.
|
||||
|
|
|
@ -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
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
Loading…
Reference in a new issue