|
PROFESSIONAL NEWSGROUPS WINDEV, WEBDEV and WINDEV Mobile |
| | | | | |
Started by adrianoboller, Dec., 12 2014 3:34 PM - 9 replies |
| |
| | | |
|
| |
Registered member 3,662 messages Popularité : +175 (223 votes) |
|
Posted on December, 12 2014 - 3:34 PM |
JSON_Analyseur
JSON_Analyseur est une Classe
GLOBAL PRIVÉ
mg_sUnicodeest une chaîne = "(\\u([0-9a-fA-F]{4}))"
mg_pclLastExprest une JSON_Expression dynamique mg_bufHASHest un Buffer
FIN
CONSTANT
JetonInvalide= 1
SourceVide= 2
TopExpressionNonValide= 3
FinInvalide= 4
JetonInattendu= 5
ObjetNomMembreInvalide= 6
ObjetMembreAucunSéparateur= 7
ObjetValeurMembreNulle= 8
ObjetSéparateurInvalide= 9
ObjetMembreVide= 10
TableauElémentSéparateurInvalide= 11
TableauElémentVide= 12
FinInattendue= 13 FIN
|
| |
| |
| | | |
|
| | |
| |
Registered member 3,662 messages Popularité : +175 (223 votes) |
|
Posted on December, 12 2014 - 3:35 PM |
Constructeur() PROCEDURE PRIVÉE Constructeur()
Destructeur() PROCEDURE Destructeur() |
| |
| |
| | | |
|
| | |
| |
Registered member 3,662 messages Popularité : +175 (223 votes) |
|
Posted on December, 12 2014 - 3:35 PM |
Method AnalyseObjet
Procedure GLOBALE PRIVÉE AnalyseObjet(pclEnumJetons est un JSON_JetonEnumérateur dynamique)
taMembres est un tableau associatif de JSON_Expression dynamique pclJeton est un JSON_Jeton dynamique sNom est une chaîne nNécessiteJetonest un entier = -1
TANTQUE pclEnumJetons.Suivant(pclJeton) _ET_ pclJeton.Type <> JSON_Jeton.ACCOLADE_DROITE
SI pclJeton.Type <> JSON_Jeton.VALEUR_CHAINE ALORS ExceptionDéclenche(ObjetNomMembreInvalide, "Déclaration invalide d'un membre d'objet. On attendait une chaîne pour le nom du membre") FIN
sNom = JSONVersChaîne(pclJeton.Données)
SI PAS pclEnumJetons.Suivant(pclJeton) ALORS ExceptionDéclenche(FinInattendue, "Fin inattendue lors de l'analyse d'un objet") FIN
SI pclJeton.Type <> JSON_Jeton.CARACTERE_DEUX_POINTS ALORS ExceptionDéclenche(ObjetMembreAucunSéparateur, "Déclaration invalide d'un membre d'objet. On attendait un séparateur entre le nom et la valeur du membre") FIN
SI PAS pclEnumJetons.Suivant(pclJeton) ALORS ExceptionDéclenche(FinInattendue, "Fin inattendue lors de l'analyse d'un objet") FIN
taMembres[sNom] = AnalyseJetons(pclEnumJetons)
SI PAS pclEnumJetons.Suivant(pclJeton) ALORS ExceptionDéclenche(FinInattendue, "Fin inattendue lors de l'analyse d'un objet") FIN
SI pclJeton.Type <> JSON_Jeton.CARACTERE_VIRGULE _ET_ pclJeton.Type <> JSON_Jeton.ACCOLADE_DROITE ALORS ExceptionDéclenche(ObjetSéparateurInvalide, "Déclaration invalide d'un membre d'objet. On attendait un séparateur entre les membres") FIN
nNécessiteJeton = (pclJeton.Type = JSON_Jeton.CARACTERE_VIRGULE)
SI pclJeton.Type = JSON_Jeton.ACCOLADE_DROITE ALORS SORTIR FIN FIN
SI pclJeton = Null _OU_ pclJeton.Type <> JSON_Jeton.ACCOLADE_DROITE ALORS ExceptionDéclenche(FinInvalide, "Déclaration invalide d'un objet. On attendait une accolade fermante") FIN
SI nNécessiteJeton <> -1 _ET_ nNécessiteJeton = Vrai ALORS ExceptionDéclenche(ObjetMembreVide, ChaîneConstruit("Déclaration d'un membre vide (%1)", pclJeton.Position)) FIN
RENVOYER JSON_Expression.ExpressionObjet(taMembres)
|
| |
| |
| | | |
|
| | |
| |
Registered member 3,662 messages Popularité : +175 (223 votes) |
|
Posted on December, 12 2014 - 3:36 PM |
Method AnalyseTableau
Procedure GLOBALE PRIVÉE AnalyseTableau(pclEnumJetons est un JSON_JetonEnumérateur dynamique)
tabValeurs est un tableau de JSON_Expression dynamique pclJetonest un JSON_Jeton dynamique nNécessiteJetonest un entier = -1
TANTQUE pclEnumJetons.Suivant(pclJeton) _ET_ pclJeton.Type <> JSON_Jeton.CROCHET_DROITE Ajoute(tabValeurs, AnalyseJetons(pclEnumJetons))
SI PAS pclEnumJetons.Suivant(pclJeton) ExceptionDéclenche(FinInattendue, "Fin inattendue lors de l'analyse d'un tableau") FIN
SI pclJeton.Type <> JSON_Jeton.CARACTERE_VIRGULE _ET_ pclJeton.Type <> JSON_Jeton.CROCHET_DROITE ALORS ExceptionDéclenche(ObjetSéparateurInvalide, "Déclaration invalide d'un élément d'un tableau. On attendait un séparateur entre les valeurs") FIN
SI pclJeton.Type = JSON_Jeton.CROCHET_DROITE ALORS SORTIR FIN FIN
SI pclJeton = Null _OU_ pclJeton.Type <> JSON_Jeton.CROCHET_DROITE ALORS ExceptionDéclenche(FinInvalide, "Déclaration invalide d'un tableau. On attendait un crochet fermant") FIN
SI nNécessiteJeton <> -1 _ET_ nNécessiteJeton = Vrai ALORS ExceptionDéclenche(TableauElémentVide, ChaîneConstruit("Déclaration d'un élément vide (%1)", pclJeton.Position)) FIN
RENVOYER JSON_Expression.ExpressionTableau(tabValeurs)
|
| |
| |
| | | |
|
| | |
| |
Registered member 3,662 messages Popularité : +175 (223 votes) |
|
Posted on December, 12 2014 - 3:36 PM |
Method JSONVersChaîne
Procedure PRIVÉE GLOBALE JSONVersChaîne(LOCAL sChaîneJSON est une chaîne)
sChaîne est une chaîne tabUnicodeest un tableau de chaîne
sChaîne = sChaîneJSON[[2 A Taille(sChaîneJSON) - 1]]
TANTQUE VérifieExpressionRégulière(sChaîne, ".*" + mg_sUnicode + ".*", tabUnicode) _ET_ tabUnicode..Occurrence = 2
sChaîne = Remplace(sChaîne, tabUnicode[1], CaractUnicode(Val(tabUnicode[2], "x"))) SupprimeTout(tabUnicode) FIN
sChaîne = Remplace(sChaîne, "\n", Caract(10)) sChaîne = Remplace(sChaîne, "\r", Caract(13)) sChaîne = Remplace(sChaîne, "\t", TAB) sChaîne = Remplace(sChaîne, "\f", "") sChaîne = Remplace(sChaîne, "\b", "") sChaîne = Remplace(sChaîne, "\""", """") sChaîne = Remplace(sChaîne, "\/", "/") sChaîne = Remplace(sChaîne, "\\", "\")
sChaîne= Remplace(sChaîne, RC, Caract(10)) sChaîne= Remplace(sChaîne, Caract(10), RC)
RENVOYER sChaîne
|
| |
| |
| | | |
|
| | |
| |
Registered member 3,662 messages Popularité : +175 (223 votes) |
|
Posted on December, 12 2014 - 3:37 PM |
Method Analyse
Procedure GLOBALE Analyse(sEntrée est une chaîne)
bufHASH est un Buffer bufHASH = HashChaîne(HA_MD5_128, sEntrée)
SI mg_bufHASH <> bufHASH ALORS
clCodeur est un JSON_JetonCodeur(sEntrée) pclEnumJetonsest un JSON_JetonEnumérateur dynamique pclTopest une JSON_Expression dynamique
pclEnumJetons = clCodeur.Encode() pclEnumJetons = pclEnumJetons.Exclure(JSON_Jeton.CARACTERE_BLANC)
dbgAssertion(pclEnumJetons.Occurrence() <> 0, "Entrée vide")
pclEnumJetons.Premier() pclTop = AnalyseJetons(pclEnumJetons)
SI pclTop <> Null ALORS
SI (pclTop.TypeNoeud <> JSON_Expression.TypeTableau _ET_ pclTop.TypeNoeud <> JSON_Expression.TypeObjet) ALORS ExceptionDéclenche(TopExpressionNonValide, "Format de sérialisation JSON incorrect") FIN FIN
mg_bufHASH = bufHASH mg_pclLastExpr = pclTop SINON
pclTop = mg_pclLastExpr FIN
RENVOYER pclTop
|
| |
| |
| | | |
|
| | |
| |
Registered member 3,662 messages Popularité : +175 (223 votes) |
|
Posted on December, 12 2014 - 3:38 PM |
Method AnalyseJetons
Procedure GLOBALE AnalyseJetons(pclEnumJetons est un JSON_JetonEnumérateur dynamique)
pclJeton est un JSON_Jeton dynamique <- pclEnumJetons.ElémentCourant pclExpressionest une JSON_Expression dynamique
SI pclJeton <> Null ALORS
SELON pclJeton.Type
CAS JSON_Jeton.ACCOLADE_GAUCHE pclExpression = AnalyseObjet(pclEnumJetons)
CAS JSON_Jeton.CROCHET_GAUCHE pclExpression = AnalyseTableau(pclEnumJetons)
CAS JSON_Jeton.BOOLEEN_FAUX pclExpression = JSON_Expression.ExpressionBooléenne(Faux)
CAS JSON_Jeton.BOOLEEN_VRAI pclExpression = JSON_Expression.ExpressionBooléenne(Vrai)
CAS JSON_Jeton.VALEUR_NULLE pclExpression = JSON_Expression.ExpressionNulle()
CAS JSON_Jeton.VALEUR_CHAINE pclExpression = JSON_Expression.ExpressionChaîne(JSONVersChaîne(pclJeton.Données))
CAS JSON_Jeton.VALEUR_NUMERIQUE pclExpression = JSON_Expression.ExpressionNumérique((pclJeton.Données))
AUTRES CAS ExceptionDéclenche(JetonInattendu, ChaîneConstruit("Jeton inattendu : %1 (%2)", pclJeton.Type, pclJeton.Position))
FIN FIN
RENVOYER pclExpression
|
| |
| |
| | | |
|
| | |
| |
Registered member 3,662 messages Popularité : +175 (223 votes) |
|
Posted on December, 12 2014 - 3:40 PM |
Declaration IJSONPropriété
IJSONPropriété est une Classe
PRIVÉ LOCAL
m_taJSONAliasest un tableau associatif de chaînes
m_taJSONIgnoreest un tableau associatif de booléens
m_taJSONAllocationest un tableau associatif de booléens
m_taAutresMembresest un tableau associatif de JSON_Expression dynamique
m_bPostAllocationest un booléen
FIN
|
| |
| |
| | | |
|
| | |
| |
Registered member 3,662 messages Popularité : +175 (223 votes) |
|
Posted on December, 12 2014 - 3:43 PM |
//Retrieving the JsonAlias property
Procedure JSONAlias()
RENVOYER m_taJSONAlias |
| |
| |
| | | |
|
| | |
| |
Registered member 3,662 messages Popularité : +175 (223 votes) |
|
Posted on June, 08 2016 - 1:35 AM |
Exemplo de Serialize
http://help.windev.com/en-US/…
ST_Product is structure
sName is string <Serialize ="ProductName"> nID is int nQty is int mValue is currency <Serialize ="Amount"> END ST_Person is structure sLastName is string <Serialize ="LastName"> sFirstName is string <Serialize ="FirstName"> dDOB is Date arrProducts is array of ST_Product END arrPersons is array of ST_Person
nPersonSubscript is int nProductSubscript is int nPersonSubscript = ArrayAdd(arrPersons) arrPersons[nPersonSubscript].sLastName = "Doe" arrPersons[nPersonSubscript].sFirstName = "John" arrPersons[nPersonSubscript].dDOB = "19880516"
nProductSubscript = ArrayAdd(arrPersons[mPersonSubscript].arrProducts) arrPersons[nPersonSubscript].arrProducts[nProductSubscript].mValue = 89.9 arrPersons[nPersonSubscript].arrProducts[nProductSubscript].nID = 12345724 arrPersons[nPersonSubscript].arrProducts[nProductSubscript].nQty = 5 arrPersons[nPersonSubscript].arrProducts[nProductSubscript].sName = "Red jacket"
bufJson is Buffer Serialize(arrPersons.bufJson, psdJSON
HTTPCreateForm("JSONForm") HTTPAddParameter("JSONForm", "JSONPERSON", bufJson) HTTPSendForm("JSONForm", ... "http://MySite/MySite_WEB/US/PAGE_Persons.awp", httpPost)
Exemplo de Deserialize
http://help.windev.com/en-US/…
MyArray is array of strings bufResult is Buffer
Add(MyArray, "WINDEV") Add(MyArray, "WEBDEV") Add(MyArray, "WINDEV MOBILE")
Serialize(MyArray, bufResult, psdJSON)
MyRebuiltArray is array of strings Deserialize(MyRebuiltArray, bufResult, psdJSON)
Exemplo de Structure
http://help.windev.com/en-US/…
ProductRef is structure SCode is int PdtCode is fixed string on 10 END
ProductRef is structure SCode is int PdtCode is fixed string on 10 END
Armchair is ProductRef
ProductRef is structure SCode is int PdtCode is fixed string on 10 END
Armchair is ProductRef Armchair:SCode = 7 Armchair:PdtCode = "Furniture"
-- Adriano José Boller ______________________________________________ Consultor e Representante Oficial da PcSoft no Brasil +55 (41) 9949 1800 adrianoboller@gmail.com skype: adrianoboller http://wxinformatica.com.br/ |
| |
| |
| | | |
|
| | | | |
| | |
| | |
| |
|
|
|