这与我之前在此问过的上一个问题有关
我试图解析相同的JSON,但现在我已经改变了我的类.
{
"lower": 20,
"upper": 40,
"delimiter": " ",
"scope": ["${title}"]
}
Run Code Online (Sandbox Code Playgroud)
我的课现在看起来像:
public class TruncateElement {
private int lower;
private int upper;
private String delimiter;
private List<AttributeScope> scope;
// getters and setters
}
public enum AttributeScope {
TITLE("${title}"),
DESCRIPTION("${description}"),
private String scope;
AttributeScope(String scope) {
this.scope = scope;
}
public String getScope() {
return this.scope;
}
}
Run Code Online (Sandbox Code Playgroud)
此代码抛出异常,
com.google.gson.JsonParseException: The JsonDeserializer EnumTypeAdapter failed to deserialized json object "${title}" given the type class com.amazon.seo.attribute.template.parse.data.AttributeScope
at
Run Code Online (Sandbox Code Playgroud)
异常是可以理解的,因为根据我之前的问题的解决方案,GSON期望实际上将Enum对象创建为
${title}("${title}"),
${description}("${description}"); …Run Code Online (Sandbox Code Playgroud) 假设我有一个包含 3 列的表格
ID INTEGER,
OFFSET INTEGER,
STR VARCHAR(50)
Run Code Online (Sandbox Code Playgroud)
包含值:
ID OFFSET STR
1 1 TestSTR1
1 2 TestSTR3
1 3 TestSTR5
2 1 TestSTR4
2 2 TestSTR2
3 1 TestSTR6
Run Code Online (Sandbox Code Playgroud)
我想为每个 ID 提取连接的“STR”(按 OFFSET 排序)。所以基本上,我想要的是:
ID STR
1 TestSTR1TestSTR3TestSTR5
2 TestSTR4TestSTR2
3 TestSTR6
Run Code Online (Sandbox Code Playgroud)
关于如何构建类似查询的任何想法?
我有一个测试字符串,如:
my $input = "testing &test ₨";
my $output = HTML::Entities::encode_entities($str,"<>&\"'");
Run Code Online (Sandbox Code Playgroud)
期望的输出是
testing &test ₨
Run Code Online (Sandbox Code Playgroud)
但HTML :: Entities :: encode_entities正在对此进行编码
testing &test &#8360;
Run Code Online (Sandbox Code Playgroud)
总而言之,我希望HTML :: Entities仅在不表示HTML实体编号的情况下对"&"字符进行编码.