小编Naf*_*lam的帖子

Dart:如何使用 json_serialized 库从 json 输入创建不同的子类

统一建模语言

在此输入图像描述

我必须序列化 json 才能从 Enum 创建特定的子类,该子类是包含抽象类目标的一个类的属性

class Test {
  Outcome outcome;
  TestType type;
}

abstract class Outcome {
  String attribute;
}

class PackageOutcome extends Outcome {
  String packageAttribute;
}

class FlexibilityOutcome extends Outcome {
  String flexibilityAttribute;
}
Run Code Online (Sandbox Code Playgroud)

Outcome 没有序列化 json 的工厂方法,但 PackageOutcome 和 FlexibilityOutcome 有。

在工厂方法中,Test.toJson()如果我有特定类型的 Enum TestType,我会创建 PackageOutcome,如果我有另一种类型,我会创建FlexibilityOutcome为测试结果。

你可以用 json_serialized 来做到这一点吗?有一些教程解释了如何做到这一点?

json dart json-serializable

5
推荐指数
0
解决办法
220
查看次数

索引器运行后,Azure 搜索不删除数据

我在 blob storage 中有一个文件folder/new/data1.json

data1 包含 json 数组。

[   
    {
        "name": "na",
        "data": {
            "1":"something1",
            "2":"something2"

        }
    },
    {
        "name": "ha",
        "data": {
            "1":"something1",
            "2":"something2"
        }
    }
]
Run Code Online (Sandbox Code Playgroud)

我的数据源正文:

{
    "name" : "datasource",
    "type" : "azureblob",
    "credentials" : { "connectionString" : "MyStorageConnStrning" },
    "container" : { "name" : "mycontaner", "query" : "folder/new" }
}   
Run Code Online (Sandbox Code Playgroud)

我的索引体:

{
    "name" : "index",
    "fields": [
       { "name": "id", "type": "Edm.String", "key": true, "searchable": false },
       { "name": "name", "type": "Edm.String", "searchable": true, …
Run Code Online (Sandbox Code Playgroud)

azure azure-cognitive-search

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

将 json 对象存储到 Azure blob 存储

有什么方法可以存储 json 对象而不将其转换为流?我可以在将其转换为流后上传。但是有没有将对象存储为 {something}.json 而不将其转换为流的方法?

我现在应该做什么

const azureStorage = require('azure-storage');
const blobService = azureStorage.createBlobService(accountName, accountKey);
var Readable = require('stream').Readable
var msg = {
   a: "something",
   b: "anotherthing"
}
var stream = new Readable
stream.push(JSON.stringify(msg))
stream.push(null)
var option = {
   contentSettings: {contentType: 'application/json'}
}
stream.pipe(blobService.createWriteStreamToBlockBlob('container', 'something.json', option, function onResponse(error, result) {
  console.log("done")
}));
Run Code Online (Sandbox Code Playgroud)

有没有更好的办法?

azure azure-storage azure-storage-blobs node.js

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

Defining a function in f#

In F# I can define a function like this

let (-+->) x y = x + y
Run Code Online (Sandbox Code Playgroud)

and call like this

let z =  5 -+-> 6
Run Code Online (Sandbox Code Playgroud)

I can even do something like this

let (-++->) x y z = x y z
let p = ((fun x -> fun y -> x + y) -++-> 5 ) 6
Run Code Online (Sandbox Code Playgroud)

But why can't I do this?

let (nafis) x y = x + y
let p = 5 nafis 6
Run Code Online (Sandbox Code Playgroud)

it …

f# functional-programming function

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

Can't modify the variables contained in another var

I have a file command_file containig a large number of commands destined to configure a router. Those lines depend on variables ($rsdp and $x2 for this example) that I collecte in my code. Here's the two first lines as an example:

/configure service sdp $rsdp mpls create

/configure service sdp $rsdp mpls description "to-$x2"

but when I lunch the perl script reading the file and sending the lines as commands to the router using Net::SSH::Expect, the variables don't change …

perl

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