Skip to content

Commit

Permalink
Revert "修改:Version"
Browse files Browse the repository at this point in the history
This reverts commit 38753c1.
  • Loading branch information
ywzou committed Sep 2, 2024
1 parent e1a89ef commit a8d06f7
Show file tree
Hide file tree
Showing 19 changed files with 38 additions and 72 deletions.
Binary file modified .gitignore
Binary file not shown.
2 changes: 1 addition & 1 deletion benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion codegen-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion codegen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
62 changes: 18 additions & 44 deletions core/src/test/java/org/apache/dubbo/jsonb/JSONBWirteTest.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
package org.apache.dubbo.jsonb;

import static org.junit.jupiter.api.Assertions.assertEquals;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONB;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.JSONWriter;
import org.apache.dubbo.jsonb.model.UserDTO;
import org.apache.dubbo.jsonb.rw.BigDecimalReader;
import org.apache.dubbo.jsonb.rw.BigDecimalWriter;
import org.junit.jupiter.api.Test;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import org.apache.dubbo.jsonb.model.UserDTO;
import org.apache.dubbo.jsonb.rw.BigDecimalReader;
import org.apache.dubbo.jsonb.rw.BigDecimalWriter;
import org.junit.jupiter.api.Test;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONB;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.JSONWriter;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class JSONBWirteTest {
@Test
public void jsonbWirteTest() {
public void wirteTest() {
// 序列化BigDecimal类型的时候添加千分位逗号
JSON.register(BigDecimal.class, BigDecimalWriter.INSTANCE);
// 反序列化BigDecimal类型的时候去除千分位逗号
Expand All @@ -35,15 +34,19 @@ public void jsonbWirteTest() {
user.setModifyDate(LocalDateTime.of(2024, 7, 2, 10, 11, 56));

// 摘至dobbo源码org.apache.dubbo.common.serialize.fastjson2.FastJson2ObjectOutput.writeObject(Object)
JSONWriter.Feature[] writeFeatures = { JSONWriter.Feature.WriteClassName, JSONWriter.Feature.FieldBased,
JSONWriter.Feature[] writeFeatures = {
JSONWriter.Feature.WriteClassName, JSONWriter.Feature.FieldBased,
JSONWriter.Feature.ErrorOnNoneSerializable, JSONWriter.Feature.ReferenceDetection,
JSONWriter.Feature.WriteNulls, JSONWriter.Feature.NotWriteDefaultValue,
JSONWriter.Feature.NotWriteHashMapArrayListClassName, JSONWriter.Feature.WriteNameAsSymbol };

// 摘至dobbo源码org.apache.dubbo.common.serialize.fastjson2.FastJson2ObjectInput.readObject(Class<T>)
JSONReader.Feature[] readerFeatures = { JSONReader.Feature.UseDefaultConstructorAsPossible,
JSONReader.Feature.ErrorOnNoneSerializable, JSONReader.Feature.IgnoreAutoTypeNotMatch,
JSONReader.Feature.UseNativeObject, JSONReader.Feature.FieldBased };
JSONReader.Feature[] readerFeatures = {
JSONReader.Feature.UseDefaultConstructorAsPossible,
JSONReader.Feature.ErrorOnNoneSerializable,
JSONReader.Feature.IgnoreAutoTypeNotMatch,
JSONReader.Feature.UseNativeObject,
JSONReader.Feature.FieldBased};

byte[] bytes = JSONB.toBytes(user, writeFeatures);
UserDTO result = JSONB.parseObject(bytes, UserDTO.class, readerFeatures);
Expand All @@ -54,33 +57,4 @@ public void jsonbWirteTest() {
assertEquals(user.getDeposit(), result.getDeposit());
assertEquals("2024-07-01", result.getActDate().format(dtf));
}

@Test
public void wirteTest() {
// 序列化BigDecimal类型的时候添加千分位逗号
JSON.register(BigDecimal.class, BigDecimalWriter.INSTANCE);
// 反序列化BigDecimal类型的时候去除千分位逗号
JSON.register(BigDecimal.class, BigDecimalReader.INSTANCE);

UserDTO user = new UserDTO();
user.setName("张三");
user.setDeposit(new BigDecimal("1000.01"));
user.setBirthday(LocalDate.now());
LocalDateTime actDate = LocalDateTime.of(2024, 7, 1, 10, 11, 56);
user.setActDate(actDate);
user.setCreateDate(LocalDateTime.of(2024, 7, 1, 10, 11, 56));
user.setModifyDate(LocalDateTime.of(2024, 7, 2, 10, 11, 56));

String text = JSON.toJSONString(user);
System.out.println(text);

UserDTO result = JSON.parseObject(text, UserDTO.class);
System.out.println(result);

DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");

assertEquals(user.getName(), result.getName());
assertEquals(user.getDeposit(), result.getDeposit());
assertEquals("2024-07-01", result.getActDate().format(dtf));
}
}
6 changes: 0 additions & 6 deletions core/src/test/java/org/apache/dubbo/jsonb/model/UserDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,4 @@ public LocalDateTime getModifyDate() {
public void setModifyDate(LocalDateTime modifyDate) {
this.modifyDate = modifyDate;
}

@Override
public String toString() {
return "UserDTO [name=" + name + ", deposit=" + deposit + ", birthday=" + birthday + ", actDate=" + actDate
+ ", createDate=" + createDate + ", modifyDate=" + modifyDate + "]";
}
}
2 changes: 1 addition & 1 deletion example-graalvm-native/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example-spring-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example-spring6-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion extension-spring5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion extension-spring6/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion fastjson1-compatible/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion incubator-vector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
12 changes: 5 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>Fastjson is a JSON processor (JSON parser + JSON generator) written in Java</description>
<packaging>pom</packaging>
Expand Down Expand Up @@ -136,14 +136,12 @@

<distributionManagement>
<repository>
<id>local-releases</id>
<name>Nexus Snapshots Repository Pro</name>
<url>http://192.168.2.200:8081/repository/maven-releases/</url>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
<id>local-snapshots</id>
<name>Nexus Releases Repository Pro</name>
<url>http://192.168.2.200:8081/repository/maven-snapshots/</url>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

Expand Down
2 changes: 1 addition & 1 deletion safemode-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion test-jdk17/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-parent</artifactId>
<version>2.0.51.01</version>
<version>2.0.52-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down

0 comments on commit a8d06f7

Please sign in to comment.