小编Vam*_*hna的帖子

如何在JSON对象中添加URL字符串

我需要通常以http:\ somewebsite.com\somepage.asp格式添加URL.当我使用上面的URL创建一个字符串并将其添加到JSON对象json时

运用

json.put("url",urlstring);
Run Code Online (Sandbox Code Playgroud)

它附加了一个额外的"\",当我检查输出时就像是 http:\\\\somewebsite.com\\somepage.asp

当我给出http://somewebsite.com/somepage.asp json输出的URL时http:\/\/somewebsite.com\/somepage.asp

你能帮我检查一下这个URL吗?

谢谢

java json

9
推荐指数
1
解决办法
3万
查看次数

如何获取Eclipse Workspace Location URI

我正在开发一个插件,它将当前工作空间的位置URI传递给其他方法.

IWorkspace workspace = ResourcesPlugin.getWorkspace();
Run Code Online (Sandbox Code Playgroud)

我是Eclipse PDE的新手.什么方法返回工作空间的URI位置.如果工作空间是C:\ Eclipse\Workspace,则为Ex.我需要路径C:\ Eclipse\Workspace

eclipse eclipse-plugin

9
推荐指数
2
解决办法
1万
查看次数

IOException:error = 7,带有大命令行的参数列表太长

我需要从Java调用Unix命令.代码如下.

String strCmd = "iconv -f "+ strSrcEncoding+" -t "+ strTgtEncoding + " <<< "+"\""+InputMessage+"\"";

String commands[] = {"bash","-c",strCmd};
Process proc = Runtime.getRuntime().exec(commands);
String strData = null;

// Get the error Stream
BufferedReader brStdError = new BufferedReader(new
        InputStreamReader(proc.getErrorStream()));
StringBuilder sbError = new StringBuilder();


// read any errors from the attempted command
while ((strData = brStdError.readLine()) != null) {
    sbError.append(strData);
}

if(sbError.toString().isEmpty())
    return "success";
else
    return "failure"+sbError.toString();
Run Code Online (Sandbox Code Playgroud)

当我传递大数据时出现错误

"bash": java.io.IOException: error=7, Argument list too long
Run Code Online (Sandbox Code Playgroud)

我尝试使用echo,如下所示

echo <<InputMessage>> | iconv -f …
Run Code Online (Sandbox Code Playgroud)

java unix process

5
推荐指数
1
解决办法
1万
查看次数

FastAPI - 未填充 ENUM 类型模型

下面是我的 fastAPI 代码

from typing import Optional, Set

from fastapi import FastAPI
from pydantic import BaseModel, HttpUrl, Field
from enum import Enum

app = FastAPI()


class Status(Enum):
    RECEIVED = 'RECEIVED'
    CREATED = 'CREATED'
    CREATE_ERROR = 'CREATE_ERROR'


class Item(BaseModel):
    name: str
    description: Optional[str] = None
    price: float
    tax: Optional[float] = None
    tags: Set[str] = []
    status: Status = None


@app.put("/items/{item_id}")
async def update_item(item_id: int, item: Item):
    results = {"item_id": item_id, "item": item}
    return results
Run Code Online (Sandbox Code Playgroud)

下面是生成的 swagger 文档。状态未显示。我是 pydantic 的新手,我不确定如何在文档中显示状态

在此处输入图片说明

python swagger openapi pydantic fastapi

4
推荐指数
1
解决办法
3754
查看次数

如何知道Linux系统中的端口是否打开

我需要找一个端口Ex.端口8080在Linux系统上打开.我正在寻找一个C或C++ API调用,它将返回true或false,或者在给定端口号时返回等效项.这只需要在本地运行.我不想知道是否有一个进程在端口上侦听,只是防火墙没有阻止它.

我想做相同的

 if( ! IsPortOpen(8080))
     cout << "please request IT to open port 8080 before running this tool";
     exit(1);
 }
Run Code Online (Sandbox Code Playgroud)

c++ linux firewall ports

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

java ×2

c++ ×1

eclipse ×1

eclipse-plugin ×1

fastapi ×1

firewall ×1

json ×1

linux ×1

openapi ×1

ports ×1

process ×1

pydantic ×1

python ×1

swagger ×1

unix ×1