protected override void AddPlugins(ItemModel source, PipelineStep pipelineStep) { base.AddPlugins(source, pipelineStep); var settings = new ReadJsonObjectsSettings { Api = GetStringValue(source, ReadJsonServiceStepItemModel.Api), RootJsonPath = GetStringValue(source, ReadJsonServiceStepItemModel.RootJsonPath) }; pipelineStep.Plugins.Add(settings); }
private JObject ExtractObject(ReadJsonObjectsSettings readJsonObjectsSettings, ILogger logger, JObject jObject) { if (jObject != null) { //select root node if (!string.IsNullOrEmpty(readJsonObjectsSettings?.RootJsonPath)) { try { jObject = jObject.SelectToken(readJsonObjectsSettings.RootJsonPath) as JObject; } catch (Exception ex) { logger.Error($"Error using '{readJsonObjectsSettings.RootJsonPath}': {ex.Message}"); } } } return(jObject); }
private JArray ExtractArray(ReadJsonObjectsSettings readJsonObjectsSettings, ILogger logger, JToken jToken) { var result = jToken == null ? new JArray() : jToken as JArray; if (result == null) { //select root node if (!string.IsNullOrEmpty(readJsonObjectsSettings?.RootJsonPath)) { try { result = jToken.SelectToken(readJsonObjectsSettings.RootJsonPath) as JArray; } catch (Exception ex) { logger.Error($"Error using '{readJsonObjectsSettings.RootJsonPath}': {ex.Message}"); } } } return(result); }