Skip to content

Commit c81e218

Browse files
authored
Merge pull request #13 from DanKE123abc/dev
v1.3.1
2 parents cda67ca + 8e5fa0b commit c81e218

File tree

5 files changed

+33
-23
lines changed

5 files changed

+33
-23
lines changed

DanKeJson.Test/Program.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Person person = new Person
1+
using DanKeJson;
2+
3+
Person person = new Person
24
{
35
Name = "张三",
46
Age = 30,
@@ -37,6 +39,13 @@
3739

3840
string json = DanKeJson.JSON.ToJson(person);
3941
Person newperson = DanKeJson.JSON.ToData<Person>(json);
42+
string json5 = DanKeJson.JSON5.ToJson(newperson, new Json5Config
43+
{
44+
AddCommaForObject = false,
45+
AddCommaForArray = false,
46+
KeyNameStyle = Json5Config.KeyNameType.WithoutQuotes,
47+
StringQuoteStyle = Json5Config.StringQuoteType.SingleQuote,
48+
});
4049

4150
Console.WriteLine(json);
4251

DanKeJson/DanKeJson.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package >
33
<metadata>
44
<id>DanKeJson</id>
5-
<version>1.3.0</version>
5+
<version>1.3.1</version>
66
<title>DanKeJson</title>
77
<authors>DanKe</authors>
88
<requireLicenseAcceptance>false</requireLicenseAcceptance>

DanKeJson/JSON.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ private static bool IsFilePath(string path)
159159
}
160160
}
161161
return true;
162-
}
163-
162+
}
164163
private static object FromJson(JsonData json, Type type)
165164
{
166165
object dataclass = Activator.CreateInstance(type);
@@ -320,8 +319,7 @@ private static object FromJson(JsonData json, Type type)
320319
propertyInfo.SetValue(dataclass, ushortValue);
321320
break;
322321
default:
323-
if (propertyType.IsGenericType &&
324-
propertyType.GetGenericTypeDefinition() == typeof(List<>))
322+
if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(List<>))
325323
{
326324
Type listType = propertyType.GetGenericArguments()[0];
327325
if (listType == typeof(string))
@@ -464,7 +462,8 @@ private static object FromJson(JsonData json, Type type)
464462
}
465463
else if (propertyType.IsClass)
466464
{
467-
var propertyValue = FromJson(json[propertyInfo.Name].ToString(), propertyType);
465+
JsonData nextjson = ToData(json[propertyInfo.Name].json);
466+
var propertyValue = FromJson(nextjson, propertyType);
468467
propertyInfo.SetValue(dataclass, propertyValue);
469468
}
470469

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ DanKeJson 为了方便开发使用,添加了许多特性,包括但不限于
3939

4040
- [ ] 解析器支持单行注释与多行注释
4141
- [ ] 支持日期格式
42+
- [ ] 支持更多 .net 版本
4243
- [X] 键名无需引号
4344
- [X] 字符串支持单引号
4445
- [X] 允许数组、对象的多余逗号
@@ -65,46 +66,46 @@ DanKeJson 为了方便开发使用,添加了许多特性,包括但不限于
6566

6667
## 在你的应用中安装 DanKeJson
6768

68-
**[点击下载](https://www.nuget.org/api/v2/package/DanKeJson/1.3.0)**
69+
**[点击下载](https://www.nuget.org/api/v2/package/DanKeJson/1.3.1)**
6970

7071
### Package manager
7172

7273
```shell
73-
NuGet\Install-Package DanKeJson -Version 1.3.0
74+
NuGet\Install-Package DanKeJson -Version 1.3.1
7475
```
7576

7677
### .NET CLI
7778

7879
```shell
79-
dotnet add package DanKeJson --version 1.3.0
80+
dotnet add package DanKeJson --version 1.3.1
8081
```
8182

8283
### PackageReference
8384

8485
```xaml
85-
<PackageReference Include="DanKeJson" Version="1.3.0" />
86+
<PackageReference Include="DanKeJson" Version="1.3.1" />
8687
```
8788

8889
### Paket CLI
8990

9091
```shell
91-
paket add DanKeJson --version 1.3.0
92+
paket add DanKeJson --version 1.3.1
9293
```
9394

9495
### Script & Interactive
9596

9697
```c#
97-
#r "nuget: DanKeJson, 1.3.0"
98+
#r "nuget: DanKeJson, 1.3.1"
9899
```
99100

100101
### Cake
101102

102103
```C#
103104
// Install DanKeJson as a Cake Addin
104-
#addin nuget:?package=DanKeJson&version=1.3.0
105+
#addin nuget:?package=DanKeJson&version=1.3.1
105106

106107
// Install DanKeJson as a Cake Tool
107-
#tool nuget:?package=DanKeJson&version=1.3.0
108+
#tool nuget:?package=DanKeJson&version=1.3.1
108109
```
109110

110111
或者,只需复制目录`./publish/DanKeJson`到您自己项目的源代码树中,并将其与您的开发环境集成。

README_en.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Deserialization:
3939

4040
- [ ] Parser support for single-line and multi-line comments
4141
- [ ] Support for date formats
42+
- [ ] Support more dotnet version
4243
- [X] Allow key names without quotes
4344
- [X] Support for single quotes in strings
4445
- [X] Allow trailing commas in arrays and objects
@@ -65,46 +66,46 @@ Serialization:
6566

6667
## Using DanKeJson from an application
6768

68-
**[Download package](https://www.nuget.org/api/v2/package/DanKeJson/1.3.0)**
69+
**[Download package](https://www.nuget.org/api/v2/package/DanKeJson/1.3.1)**
6970

7071
### Package manager
7172

7273
```shell
73-
NuGet\Install-Package DanKeJson -Version 1.3.0
74+
NuGet\Install-Package DanKeJson -Version 1.3.1
7475
```
7576

7677
### .NET CLI
7778

7879
```shell
79-
dotnet add package DanKeJson --version 1.3.0
80+
dotnet add package DanKeJson --version 1.3.1
8081
```
8182

8283
### PackageReference
8384

8485
```xaml
85-
<PackageReference Include="DanKeJson" Version="1.3.0" />
86+
<PackageReference Include="DanKeJson" Version="1.3.1" />
8687
```
8788

8889
### Paket CLI
8990

9091
```shell
91-
paket add DanKeJson --version 1.3.0
92+
paket add DanKeJson --version 1.3.1
9293
```
9394

9495
### Script & Interactive
9596

9697
```c#
97-
#r "nuget: DanKeJson, 1.3.0"
98+
#r "nuget: DanKeJson, 1.3.1"
9899
```
99100

100101
### Cake
101102

102103
```C#
103104
// Install DanKeJson as a Cake Addin
104-
#addin nuget:?package=DanKeJson&version=1.3.0
105+
#addin nuget:?package=DanKeJson&version=1.3.1
105106

106107
// Install DanKeJson as a Cake Tool
107-
#tool nuget:?package=DanKeJson&version=1.3.0
108+
#tool nuget:?package=DanKeJson&version=1.3.1
108109
```
109110

110111
Alternatively, just copy the whole tree of files under `./publish/DanKeJson` to your own project's source tree and integrate it with your development environment.

0 commit comments

Comments
 (0)