我正在处理JSON中的一些日期信息。我正在使用Shopify的液体模板来遍历JSON并提取日期时间输入值。 这是我输入的示例:
try
{
//Variablen für die Verarbeitung
string source_file = @"C:\temp\offer.pdf";
string web_url = "https://stackoverflow.sharepoint.com";
string library_name = "Documents";
string admin_name = "admin@stackoverflow.com";
string admin_password = "Password";
//Verbindung mit den Login-Daten herstellen
var sercured_password = new SecureString();
foreach (var c in admin_password) sercured_password.AppendChar(c);
SharePointOnlineCredentials credent = new
SharePointOnlineCredentials(admin_name, sercured_password);
//Context mit Credentials erstellen
ClientContext context = new ClientContext(web_url);
context.Credentials = credent;
//Bibliothek festlegen
var library = context.Web.Lists.GetByTitle(library_name);
//Ausgewählte Datei laden
FileStream fs = System.IO.File.OpenRead(source_file);
//Dateinamen aus Pfad ermitteln
string source_filename = Path.GetFileName(source_file);
//Datei ins SharePoint-Verzeichnis hochladen
FileCreationInformation fci = new FileCreationInformation();
fci.Overwrite = true;
fci.ContentStream = fs;
fci.Url = source_filename;
var file_upload = library.RootFolder.Files.Add(fci);
//Ausführen
context.Load(file_upload);
context.ExecuteQuery();
//Datenübertragen schließen
fs.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Fehler");
throw;
}
我们开发的简易命令是:
{
"BookSet" :
{
"CreatedDate" : "2019-04-25T12:30:00+01:00",
"Price": "$20",
"Title": "Basic Tech"
}
}
我们收到的输出是:
<set-body template="liquid">{
{% assign responsePayload = body.BookSet %}
"Data":
{
"Publish_Date":"{{responsePayload.CreatedDate}}"
}
</set-body>
但是我们不希望此处的日期时间值调整为GMT时区。 我们的预期输出应为:
{
"Data":
{
"Publish_Date":"4/25/2019 11:30:00 AM"
}
}
我们尝试使用捕获功能将此日期值转换为字符串,但这也无法正常工作。