mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add BeanPath
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
package org.dromara.hutool.json;
|
||||
|
||||
import org.dromara.hutool.core.bean.BeanPathOld;
|
||||
import org.dromara.hutool.core.bean.path.BeanPath;
|
||||
import org.dromara.hutool.core.convert.ConvertException;
|
||||
import org.dromara.hutool.core.convert.Converter;
|
||||
import org.dromara.hutool.core.lang.mutable.MutableEntry;
|
||||
@@ -64,11 +64,11 @@ public interface JSON extends Converter, Cloneable, Serializable {
|
||||
*
|
||||
* @param expression 表达式
|
||||
* @return 对象
|
||||
* @see BeanPathOld#get(Object)
|
||||
* @see BeanPath#getValue(Object)
|
||||
* @since 4.0.6
|
||||
*/
|
||||
default Object getByPath(final String expression) {
|
||||
return BeanPathOld.of(expression).get(this);
|
||||
return BeanPath.of(expression).getValue(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +93,7 @@ public interface JSON extends Converter, Cloneable, Serializable {
|
||||
* @param value 值
|
||||
*/
|
||||
default void putByPath(final String expression, final Object value) {
|
||||
BeanPathOld.of(expression).set(this, value);
|
||||
BeanPath.of(expression).setValue(this, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,11 +118,11 @@ public interface JSON extends Converter, Cloneable, Serializable {
|
||||
* @param expression 表达式
|
||||
* @param resultType 返回值类型
|
||||
* @return 对象
|
||||
* @see BeanPathOld#get(Object)
|
||||
* @see BeanPath#getValue(Object)
|
||||
* @since 4.0.6
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
default <T> T getByPath(final String expression, final Type resultType){
|
||||
default <T> T getByPath(final String expression, final Type resultType) {
|
||||
return (T) config().getConverter().convert(resultType, getByPath(expression));
|
||||
}
|
||||
|
||||
|
@@ -340,7 +340,7 @@ public class JWT implements RegisteredPayload<JWT> {
|
||||
*
|
||||
* <p>此方法会补充如下的header:</p>
|
||||
* <ul>
|
||||
* <li>当用户未定义"typ"时,赋默认值:"JWT"</li>
|
||||
* <li>当用户未定义"typ"时,不设置默认值</li>
|
||||
* <li>当用户未定义"alg"时,根据传入的{@link JWTSigner}对象类型,赋值对应ID</li>
|
||||
* </ul>
|
||||
*
|
||||
@@ -350,12 +350,6 @@ public class JWT implements RegisteredPayload<JWT> {
|
||||
public String sign(final JWTSigner signer) {
|
||||
Assert.notNull(signer, () -> new JWTException("No Signer provided!"));
|
||||
|
||||
// 检查tye信息
|
||||
final String type = (String) this.header.getClaim(JWTHeader.TYPE);
|
||||
if (StrUtil.isBlank(type)) {
|
||||
this.header.setType("JWT");
|
||||
}
|
||||
|
||||
// 检查头信息中是否有算法信息
|
||||
final String algorithm = (String) this.header.getClaim(JWTHeader.ALGORITHM);
|
||||
if (StrUtil.isBlank(algorithm)) {
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
package org.dromara.hutool.json.jwt;
|
||||
|
||||
import org.dromara.hutool.core.map.MapUtil;
|
||||
import org.dromara.hutool.json.jwt.signers.JWTSigner;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -29,7 +30,7 @@ public class JWTUtil {
|
||||
* @return JWT Token
|
||||
*/
|
||||
public static String createToken(final Map<String, Object> payload, final byte[] key) {
|
||||
return createToken(null, payload, key);
|
||||
return createToken(MapUtil.of(JWTHeader.TYPE, "JWT"), payload, key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user