forked from lxm_flutter/json2dart
first commit
This commit is contained in:
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Files and directories created by pub
|
||||
.dart_tool/
|
||||
.packages
|
||||
# Remove the following pattern if you wish to check in your lock file
|
||||
pubspec.lock
|
||||
|
||||
# Conventional directory for build outputs
|
||||
build/
|
||||
|
||||
# Directory created by dartdoc
|
||||
doc/api/
|
||||
3
CHANGELOG.md
Normal file
3
CHANGELOG.md
Normal file
@@ -0,0 +1,3 @@
|
||||
## 1.0.0
|
||||
|
||||
- Initial version, created by Stagehand
|
||||
6
README.md
Normal file
6
README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# hello_world
|
||||
|
||||
An absolute bare-bones web app.
|
||||
|
||||
Created from templates made available by Stagehand under a BSD-style
|
||||
[license](https://github.com/dart-lang/stagehand/blob/master/LICENSE).
|
||||
14
analysis_options.yaml
Normal file
14
analysis_options.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
analyzer:
|
||||
# exclude:
|
||||
# - path/to/excluded/files/**
|
||||
|
||||
# Lint rules and documentation, see http://dart-lang.github.io/linter/lints
|
||||
linter:
|
||||
rules:
|
||||
- cancel_subscriptions
|
||||
- hash_and_equals
|
||||
- iterable_contains_unrelated_type
|
||||
- list_remove_unrelated_type
|
||||
- test_types_in_equals
|
||||
- unrelated_type_equality_checks
|
||||
- valid_regexps
|
||||
15
pubspec.yaml
Normal file
15
pubspec.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
name: hello_world
|
||||
description: An absolute bare-bones web app.
|
||||
# version: 1.0.0
|
||||
#homepage: https://www.example.com
|
||||
#author: Caijinglong <email@example.com>
|
||||
|
||||
environment:
|
||||
sdk: '>=2.0.0-dev.68.0 <3.0.0'
|
||||
|
||||
#dependencies:
|
||||
# path: ^1.4.1
|
||||
|
||||
dev_dependencies:
|
||||
build_runner: ^0.9.0
|
||||
build_web_compilers: ^0.4.0
|
||||
BIN
web/favicon.ico
Normal file
BIN
web/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
36
web/index.html
Normal file
36
web/index.html
Normal file
@@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="scaffolded-by" content="https://github.com/google/stagehand">
|
||||
<title>hello_world</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<link rel="icon" href="favicon.ico">
|
||||
<script defer src="main.dart.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div>
|
||||
<div id="input" class="textarea">
|
||||
<div class="top">
|
||||
将json粘贴至左边
|
||||
</div>
|
||||
<textarea id="json"></textarea>
|
||||
<div>
|
||||
<button id="format">点击</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="output" class="textarea">
|
||||
<div class="top"></div>
|
||||
<textarea id="result"></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
18
web/main.dart
Normal file
18
web/main.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:html';
|
||||
|
||||
void main() {
|
||||
querySelector("#format").onClick.listen((event) {
|
||||
TextAreaElement e = querySelector("#json");
|
||||
var string = e.value;
|
||||
var pretty = formatJson(string);
|
||||
e.value = pretty;
|
||||
});
|
||||
}
|
||||
|
||||
String formatJson(String jsonString) {
|
||||
var map = json.decode(jsonString);
|
||||
var prettyStringList = JsonUtf8Encoder(" ").convert(map);
|
||||
var prettyString = String.fromCharCodes(prettyStringList);
|
||||
return prettyString;
|
||||
}
|
||||
28
web/styles.css
Normal file
28
web/styles.css
Normal file
@@ -0,0 +1,28 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=Roboto);
|
||||
|
||||
html,
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: "Roboto", sans-serif;
|
||||
}
|
||||
|
||||
.top {
|
||||
height: 4vh;
|
||||
text-align: center;
|
||||
padding-top: 1vh;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
width: 50%;
|
||||
height: 90%;
|
||||
text-align: center;
|
||||
float: left;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 90%;
|
||||
height: 90vh;
|
||||
}
|
||||
Reference in New Issue
Block a user