小编Sta*_*nza的帖子

识别属性的值是一个数组

我有一个JSON文件:

{  
   "abn":"63119059513",
   "acn":"119059513",
   "business_structure":"Private Company",
   "ngr_number":"1231231",
   "cbh_number":"1231231",
   "main_name":"Brickworks Building Products Pty Ltd",
   "trading_name":"Brickworks",
   "other_trading_names":"Austral Bricks",
   "directors":[  
      {  
         "ID":"12114",
         "ae_forms_filled_in_ID":"22739",
         "name":"John Smith",
         "dob":"1983-10-29",
         "address_line_1":"123 Fake Street",
         "address_line_2":"",
         "address_line_city":"Fakeland",
         "address_line_postcode":"2000",
         "address_line_state":"New South Wales",
         "address_line_country":"Australia",
         "order_extract_id":null,
         "director_found":null,
         "drivers_lic":"",
         "home_mortgage":"",
         "phone":"",
         "mobile":"",
         "director_email":"",
         "director_title":"Mr",
         "director_position":"Director",
         "dir_pdf_url":null
      }
   ],

}
Run Code Online (Sandbox Code Playgroud)

我想确定任何属性的值是否具有数组结构.到目前为止我能想出的最好的是:

StreamReader streamrr = new StreamReader("C:\\temp\\agfarm_example_udate.json", Encoding.UTF8);

string JSON = streamrr.ReadToEnd();

JObject CWFile = JObject.Parse(JSON);
foreach (JProperty property in CWFile.Properties())
{
    // Do something

    if (property.Value.ToString().Contains("["))
    {
        // Do something with the array
        JArray …
Run Code Online (Sandbox Code Playgroud)

c# json json.net

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

持久函数 - 活动函数内的可等待任务

我有一个持久函数,其输入由先前的活动函数确定。对于每个活动函数,我有多个可等待的任务,其中每个任务都依赖于前一个任务的输出。

这是我的结构如下:

协调者

[FunctionName("MessageController")]
public static async void Run(
    [OrchestrationTrigger] DurableOrchestrationContext context,
    TraceWriter log)
{
    if (!context.IsReplaying) log.Warning("MessageController started");

    var Input1= context.CallActivityAsync<ResultMessage>("Function_1", new InputMessage());
    var Input2= context.CallActivityAsync<ResultMessage>("Function_2", Input1);
    var Input3= context.CallActivityAsync<ResultMessage>("Function_2", Input2);

}
Run Code Online (Sandbox Code Playgroud)

活动功能

[FunctionName("Function_1")]
public static ResultMessage Run(
    [ActivityTrigger] DurableActivityContext activityContext,
    TraceWriter log)
{
    //Awaitable task
    var taskOutput= await DoSomething();

    //Awaitable task
    var token = await DoAnotherThing(taskOutput);
}
Run Code Online (Sandbox Code Playgroud)

我已经对此进行了测试,一切正常。但我想知道这是否是好的做法?对于持久函数来说,在活动函数中存在可等待任务是否正常?

azure async-await azure-functions azure-durable-functions

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