<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel><category>pcsoft.fr.windev</category><copyright>Copyright 2026, PC SOFT</copyright><lastBuildDate>6 Apr 2020 10:13:21 Z</lastBuildDate><pubDate>6 Apr 2020 08:32:17 Z</pubDate><description>Bonjour,&#13;
&#13;
Je rencontre actuellement un souci de formatage de date avec les fonctions Windev VariantVersJSON et JSONVersVariant.&#13;
Le VariantVersJSON me sérialise un membre de Variant de type date au format AAAA-MM-JJ&#13;
Le JSONVersVariant me renvoie du coup une valeur qui ne sera pas reconnue pour mes futurs traitements.&#13;
&#13;
Ci-dessous mon test unitaire : &#13;
[code:wl]&#13;
date est une Date&#13;
date = "20200406"&#13;
&#13;
index est un Variant&#13;
index.date = date&#13;
Trace( "index.date : " + index.date )&#13;
// Affiche index.date : 20200406&#13;
&#13;
json est un JSON&#13;
json = VariantVersJSON( index )&#13;
Trace( "json après VariantVersJSON : " + json )&#13;
// Affiche json après VariantVersJSON : { "date":"2020-04-06" }&#13;
&#13;
index = JSONVersVariant( json )&#13;
Trace( "index.date après JSONVersVariant : " + index.date )&#13;
// Affiche index.date après JSONVersVariant : 2020-04-06&#13;
[/code]&#13;
Si je remplace date = "20200406" par date = Datesys(), j'obtiens le même résultat.&#13;
Par contre si je remplace index.date = Datesys(), le résultat est correct :&#13;
[code:wl]&#13;
index est un Variant&#13;
index.date = DateSys()&#13;
Trace( "index.date : " + index.date )&#13;
// Affiche index.date : 20200406&#13;
&#13;
json est un JSON&#13;
json = VariantVersJSON( index )&#13;
Trace( "json après VariantVersJSON : " + json )&#13;
// Affiche json après VariantVersJSON : { "date":"20200406" }&#13;
&#13;
index = JSONVersVariant( json )&#13;
Trace( "index.date après JSONVersVariant : " + index.date )&#13;
// Affiche index.date après JSONVersVariant : 20200406&#13;
[/code]&#13;
&#13;
Y-a-t-il un moyen de préserver la date au format AAAAMMJJ pendant les phases de conversion ?</description><ttl>30</ttl><generator>WEBDEV</generator><language>fr_FR</language><link>https://forum.pcsoft.fr/es-ES/pcsoft.fr.windev/238362-souci-format-date-entre-json-variant/read.awp</link><title>Souci format date entre json et variant</title><managingEditor>moderateur@pcsoft.fr (El moderador)</managingEditor><webMaster>webmaster@pcsoft.fr (El webmaster)</webMaster><item><author>Julien V</author><category>pcsoft.fr.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.fr.windev/238362-souci-format-date-entre-json-variant-238373/read.awp</comments><pubDate>6 Apr 2020 10:13:21 Z</pubDate><description>Bonjour Benjamin,&#13;
&#13;
Merci pour cette réponse très claire, effectivement en forçant en chaîne ça fonctionne.&#13;
&#13;
Je ne savais pas…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.fr.windev/238362-souci-format-date-entre-json-variant-238373/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.fr.windev/238362-souci-format-date-entre-json-variant-238373/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.fr.windev/238362-souci-format-date-entre-json-variant/read.awp">Souci format date entre json et variant</source><title>Re: Souci format date entre json et variant</title></item><item><author>bchanudet</author><category>pcsoft.fr.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.fr.windev/238362-souci-format-date-entre-json-variant-238367/read.awp</comments><pubDate>6 Apr 2020 09:01:26 Z</pubDate><description>Bonjour,&#13;
&#13;
Dans votre premier exemple, vous assignez une variable de type date directement dans le variant. La fonction Variant…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.fr.windev/238362-souci-format-date-entre-json-variant-238367/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.fr.windev/238362-souci-format-date-entre-json-variant-238367/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.fr.windev/238362-souci-format-date-entre-json-variant/read.awp">Souci format date entre json et variant</source><title>Re: Souci format date entre json et variant</title></item></channel></rss>
