小编Hus*_*ali的帖子

如何在 Json Schema 4 中定义百分比类型的属性

我正在设计一个 Json 模式,我想显示百分比。我不确定我应该选择哪种类型来定义 Json 模式中的百分比。任何帮助,将不胜感激。

"rate": { "type": "percentage" }
Run Code Online (Sandbox Code Playgroud)

json jsonschema

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

python中的TCP Traceroute

我正在编写一个python脚本来执行'TCP Traceroute'.我学会了scapy这是一个很有用的库,但是我没有得到我需要的结果.谁能帮我解决这个问题?我希望python脚本生成与命令行类似的结果.

我使用linux,python 2.7和scapy 2.4.我不确定为什么所有跳跃都显示相同的IP地址.

from scapy.layers.inet import traceroute

result, unans = traceroute('172.217.17.46', maxttl=30)
   for snd, rcv in result:
   print snd.ttl, rcv.src, snd.sent_time, rcv.time
Run Code Online (Sandbox Code Playgroud)

当我运行此代码时,我得到以下结果:

1 10.0.2.2 1541113255.58 1541113255.6
2 172.217.17.46 1541113255.58 1541113255.72
3 172.217.17.46 1541113255.58 1541113255.72
4 172.217.17.46 1541113255.58 1541113255.72
5 172.217.17.46 1541113255.59 1541113255.73
6 172.217.17.46 1541113255.59 1541113255.73
7 172.217.17.46 1541113255.6 1541113255.74
8 172.217.17.46 1541113255.6 1541113255.74
9 172.217.17.46 1541113255.6 1541113255.74
10 172.217.17.46 1541113255.61 1541113255.75
11 172.217.17.46 1541113255.61 1541113255.75
12 172.217.17.46 1541113255.61 1541113255.75
13 172.217.17.46 1541113255.62 1541113255.76
14 172.217.17.46 1541113255.62 …
Run Code Online (Sandbox Code Playgroud)

python traceroute scapy

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

Json Schema - 如何使任意两个或多个属性成为必需

我有这个父架构:

{
    "definitions": {
        "parcel": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "string"
                },
                "accountNumber": {
                    "type": "string"
                },
                "parcelNumber": {
                    "type": "string"
                },
                "propertyType": {
                    "type": "string"
                },
                "address": {
                    "$ref": "address.json#/definitions/address"
                },
                "coordinates": {
                    "$ref": "coordinates.json#/definitions/coordinates"
                }
            },
            "required": ["accountNumber", "parcelNumber"]
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

以下是引用的子模式:

{
    "definitions": {
        "address": {
            "type": "object",
            "properties": {
                "addressString": {
                    "type": "string",
                    "addressType": {
                        "enum": ["residential", "business"]
                    }
                },
                "required": ["addressString"]
            }
        }
    }
}

    {
    "definitions": {
        "coordinates": {
            "type": …
Run Code Online (Sandbox Code Playgroud)

json jsonschema

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

C# 单元测试 - 无法从 IHttpActionResult 响应中提取内容

我有这个控制器

    [Route("GeocacheAddressObjectList")]
    [HttpPost]
    public async Task<IHttpActionResult> GeocacheAddressObjectList([FromBody] List<GeocacheAddress> addresses)
    {
        //check valid addresses
        if(addresses == null)
        {
            return BadRequest("Invalid addresses. The address list object is null!") as IHttpActionResult;
        }

        ElasticHelper searchHelper = new ElasticHelper(ConfigurationManager.AppSettings["ElasticSearchUri"]);
        List<GeocacheAddress> geocodedAddresses = new List<GeocacheAddress>();

        // check each address in the addresses list against geocache db
        foreach (GeocacheAddress address in addresses)
        {
            var elasticSearchResult = SearchGeocacheIndex(address);

            // found a match
            if (elasticSearchResult.Total != 0)
            {
                SearchProperties standardizedAddressSearch = new SearchProperties();
                standardizedAddressSearch.Size = 1;
                standardizedAddressSearch.From = 0; …
Run Code Online (Sandbox Code Playgroud)

c# asp.net unit-testing asp.net-web-api

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