diff --git a/JSONPreview.podspec b/JSONPreview.podspec
index 64b9685..003bb5f 100755
--- a/JSONPreview.podspec
+++ b/JSONPreview.podspec
@@ -5,7 +5,7 @@ Pod::Spec.new do |s|
s.name = 'JSONPreview'
- s.version = '1.3.5'
+ s.version = '1.3.6'
s.summary = '🎨 A view that can be highlighted after formatting JSON.'
diff --git a/JSONPreview.xcodeproj/project.pbxproj b/JSONPreview.xcodeproj/project.pbxproj
index 0e7d603..11912b4 100644
--- a/JSONPreview.xcodeproj/project.pbxproj
+++ b/JSONPreview.xcodeproj/project.pbxproj
@@ -501,7 +501,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 13;
+ CURRENT_PROJECT_VERSION = 14;
DEVELOPMENT_TEAM = 5C9JW4S9DE;
INFOPLIST_FILE = "$(SRCROOT)/JSONPreview/Other/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
@@ -509,7 +509,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
- MARKETING_VERSION = 1.3.5;
+ MARKETING_VERSION = 1.3.6;
PRODUCT_BUNDLE_IDENTIFIER = com.rakuyo.JSONPreview;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
@@ -523,7 +523,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 13;
+ CURRENT_PROJECT_VERSION = 14;
DEVELOPMENT_TEAM = 5C9JW4S9DE;
INFOPLIST_FILE = "$(SRCROOT)/JSONPreview/Other/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
@@ -531,7 +531,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
- MARKETING_VERSION = 1.3.5;
+ MARKETING_VERSION = 1.3.6;
PRODUCT_BUNDLE_IDENTIFIER = com.rakuyo.JSONPreview;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
diff --git a/JSONPreview/Core/JSONLexer.swift b/JSONPreview/Core/JSONLexer.swift
index 50df4db..26c1059 100644
--- a/JSONPreview/Core/JSONLexer.swift
+++ b/JSONPreview/Core/JSONLexer.swift
@@ -280,6 +280,15 @@ private extension JSONLexer {
if first.isNumber || first == "." {
number += String(first)
_first = tmpJSON.removeFirst()
+ }
+
+ // Scientific counting support
+ else if first.lowercased() == "e",
+ let next = tmpJSON.first,
+ (next == "+" || next == "-" || next.isNumber) {
+
+ number += (String(first) + String(tmpJSON.removeFirst()))
+ _first = tmpJSON.removeFirst()
} else {
tmpJSON = String(first) + tmpJSON
diff --git a/JSONPreview/Other/ViewController.swift b/JSONPreview/Other/ViewController.swift
index 3f90dcf..34c0105 100644
--- a/JSONPreview/Other/ViewController.swift
+++ b/JSONPreview/Other/ViewController.swift
@@ -48,6 +48,7 @@ class ViewController: UIViewController {
[
{
"string" : "string",
+ "int" : 1024,
"float" : 3.1415926,
"negative_numbers" : -50,
"bool_true" : true,
@@ -65,6 +66,7 @@ class ViewController: UIViewController {
"effects_in_array" : [
"string",
3.1415926,
+ 1024,
-50,
true,
false,
@@ -80,6 +82,16 @@ class ViewController: UIViewController {
{},
]
},
+ {
+ "exponential_value": [
+ 1024e+23,
+ -25e+23,
+ -25e-23,
+ 2.54e23,
+ 3.1415926E+23,
+ 3.1415926E-23,
+ ]
+ },
{
"quotes_string": "This is a string that has some \\"quotes\\" inside it!",
"very_long_value" : "A very very very very very very very very very very very very long string."
@@ -104,7 +116,15 @@ class ViewController: UIViewController {
]
"""
- previewView.preview(json, style: .default)
+ let start = Date().timeIntervalSince1970
+ print("will display json")
+
+ previewView.preview(json, style: .default) {
+ let end = Date().timeIntervalSince1970
+ let timeConsuming = end - start
+
+ print("did display json at: \(timeConsuming)")
+ }
}
}
diff --git a/JSONPreviewTests/Info.plist b/JSONPreviewTests/Info.plist
index 9a9149c..f5d99ac 100644
--- a/JSONPreviewTests/Info.plist
+++ b/JSONPreviewTests/Info.plist
@@ -15,8 +15,8 @@
CFBundlePackageType
$(PRODUCT_BUNDLE_PACKAGE_TYPE)
CFBundleShortVersionString
- 1.3.5
+ 1.3.6
CFBundleVersion
- 13
+ 14
diff --git a/JSONPreviewUITests/Info.plist b/JSONPreviewUITests/Info.plist
index 9a9149c..f5d99ac 100644
--- a/JSONPreviewUITests/Info.plist
+++ b/JSONPreviewUITests/Info.plist
@@ -15,8 +15,8 @@
CFBundlePackageType
$(PRODUCT_BUNDLE_PACKAGE_TYPE)
CFBundleShortVersionString
- 1.3.5
+ 1.3.6
CFBundleVersion
- 13
+ 14
diff --git a/README.md b/README.md
index ff41033..957e65d 100644
--- a/README.md
+++ b/README.md
@@ -132,6 +132,7 @@ For rendering, `JSONPreview` performs only **limited** formatting checks, includ
- `"` must occur in pairs.
- The previous node of `"` can only be one of `{`, `[`, `,` and `:`.
- Spell checking for `null`, `true`, and `false`.
+- For scientific notation, the next node of `{E/e}` must be `+`, `-` or a number.
Any other syntax errors will not trigger a rendering error.
diff --git a/README_CN.md b/README_CN.md
index cd7be59..e27a391 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -130,6 +130,7 @@ previewView.preview(json, style: style)
- `"` 必须成对出现。
- `"` 的上一个节点只能是 `{`、`[`、`,` 以及 `:` 中的一个。
- 针对 `null`、`true` 以及 `false` 的拼写检查。
+- 针对科学计数法,`{E/e}` 的下一个节点必须是 `+`、`-` 或数字。
除此之外的语法错误均不会触发渲染错误。