unable to deserialize result with property name with dashes
gecko2308 opened this issue · 8 comments
Here is my answer from the api
{
"http_method":"GET",
"revision":"f38252d751a447443410a7639e54d791",
"results":{
"language":"english",
"gui-ipv6":"disable",
"gui-certificates":"enable",
},
"build":1142
}
Here is a sample of property in my class:
<JsonProperty(PropertyName:="admin-https-ssl-versions")>
Public Property adminhttpssslversions As String
I haved tried to use JsonProperty but add no effect.
Property which have no "-" get populated with the data but not the other.
@gcogneau Hi. Please post the code that relates to RestClient.Net.
Async Function api_global() As Task(Of Response)
ServicePointManager.ServerCertificateValidationCallback = AddressOf AcceptAllCertifications
Dim client = New Client(New JsonSerializationAdapter(), New Uri("https://192.168.2.222:8443/api/v2/cmdb/system/global?access_token=qd578y9mczfj40Q1rcf4n50fzGG1mN"))
Try
Dim response = Await client.GetAsync(Of api_global)()
Console.WriteLine(response.IsSuccess)
Return response
Catch ex As Exception
Console.WriteLine(ex.Message)
Return Nothing
End Try
End Function
Imports System.Runtime.Serialization
Imports Newtonsoft.Json
Public Class api_global
Public Property http_method As String
Public Property revision As String
Public Property results As Results
Public Property vdom As String
Public Property path As String
Public Property name As String
Public Property status As String
Public Property http_status As Integer
Public Property serial As String
Public Property version As String
Public Property build As Integer
End Class
Public Class Results
Public Property language As String
<JsonProperty(PropertyName:="gui-ipv6")>
Public Property guiipv6 As String
Public Property gui_certificates As String
Public Property guicustomlanguage As String
Public Property guiwirelessopensecurity As String
Public Property guidisplayhostname As String
Public Property guifortisandboxcloud As String
Public Property guilinesperpage As Integer
<JsonProperty(PropertyName:="admin-https-ssl-versions")>
Public Property adminhttpssslversions As String
Public Property admintimeout As Integer
Public Property adminconsoletimeout As Integer
Public Property ssdtrimfreq As String
Public Property ssdtrimhour As Integer
Public Property ssdtrimmin As Integer
Public Property ssdtrimweekday As String
Public Property ssdtrimdate As Integer
Public Property adminconcurrent As String
Public Property adminlockoutthreshold As Integer
Public Property adminlockoutduration As Integer
Public Property refresh As Integer
Public Property interval As Integer
Public Property failtime As Integer
Public Property dailyrestart As String
Public Property restarttime As String
Public Property radiusport As Integer
Public Property adminloginmax As Integer
Public Property remoteauthtimeout As Integer
Public Property ldapconntimeout As Integer
Public Property batchcmdb As String
Public Property multifactorauthentication As String
Public Property sslminprotoversion As String
Public Property autorunlogfsck As String
Public Property dst As String
Public Property timezone As String
Public Property trafficpriority As String
Public Property trafficprioritylevel As String
Public Property antireplay As String
Public Property sendpmtuicmp As String
Public Property honordf As String
Public Property revisionimageautobackup As String
Public Property revisionbackuponlogout As String
Public Property managementvdom As String
Public Property hostname As String
Public Property guiallowdefaulthostname As String
Public Property _alias As String
Public Property strongcrypto As String
Public Property sshcbccipher As String
Public Property sshhmacmd5 As String
Public Property sshkexsha1 As String
Public Property sshmacweak As String
Public Property sslstatickeyciphers As String
Public Property snatroutechange As String
Public Property cliauditlog As String
Public Property dhparams As String
Public Property fdsstatistics As String
Public Property fdsstatisticsperiod As Integer
Public Property tcpoption As String
Public Property lldptransmission As String
Public Property lldpreception As String
Public Property proxyauthtimeout As Integer
Public Property proxyreauthenticationmode As String
Public Property proxyauthlifetime As String
Public Property proxyauthlifetimetimeout As Integer
Public Property sysperfloginterval As Integer
Public Property checkprotocolheader As String
Public Property viparprange As String
Public Property resetsessionlesstcp As String
Public Property allowtrafficredirect As String
Public Property strictdirtysessioncheck As String
Public Property tcphalfclosetimer As Integer
Public Property tcphalfopentimer As Integer
Public Property tcptimewaittimer As Integer
Public Property udpidletimer As Integer
Public Property blocksessiontimer As Integer
Public Property ipsrcportrange As String
Public Property preloginbanner As String
Public Property postloginbanner As String
Public Property tftp As String
Public Property avfailopen As String
Public Property avfailopensession As String
Public Property memoryusethresholdextreme As Integer
Public Property memoryusethresholdred As Integer
Public Property memoryusethresholdgreen As Integer
Public Property cpuusethreshold As Integer
Public Property checkresetrange As String
Public Property vdommode As String
Public Property vdomadmin As String
Public Property longvdomname As String
Public Property adminport As Integer
Public Property adminsport As Integer
Public Property adminhttpsredirect As String
Public Property adminhstsmaxage As Integer
Public Property adminsshpassword As String
Public Property adminrestrictlocal As String
Public Property adminsshport As Integer
Public Property adminsshgracetime As Integer
Public Property adminsshv1 As String
Public Property admintelnet As String
Public Property admintelnetport As Integer
Public Property defaultservicesourceport As String
Public Property adminmaintainer As String
Public Property adminservercert As String
Public Property userservercert As String
Public Property adminhttpspkirequired As String
Public Property wificertificate As String
Public Property wificacertificate As String
Public Property authhttpport As Integer
Public Property authhttpsport As Integer
Public Property authkeepalive As String
Public Property policyauthconcurrent As Integer
Public Property authsessionlimit As String
Public Property authcert As String
Public Property cltcertreq As String
Public Property fortiserviceport As Integer
Public Property cfgsave As String
Public Property cfgreverttimeout As Integer
Public Property rebootuponconfigrestore As String
Public Property adminscp As String
Public Property securityratingresultsubmission As String
Public Property securityratingrunonschedule As String
Public Property wirelesscontroller As String
Public Property wirelesscontrollerport As Integer
Public Property fortiextenderdataport As Integer
Public Property fortiextender As String
Public Property fortiextendervlanmode As String
Public Property switchcontroller As String
Public Property switchcontrollerreservednetwork As String
Public Property dnsproxyworkercount As Integer
Public Property urlfiltercount As Integer
Public Property proxyworkercount As Integer
Public Property scanunitcount As Integer
Public Property proxykxphardwareacceleration As String
Public Property proxycipherhardwareacceleration As String
Public Property fgdalertsubscription As String
Public Property ipsechmacoffload As String
Public Property ipv6acceptdad As Integer
Public Property ipv6allowanycastprobe As String
Public Property csrcaattribute As String
Public Property wimax4gusb As String
Public Property certchainmax As Integer
Public Property sslvpnmaxworkercount As Integer
Public Property sslvpnpluginversioncheck As String
Public Property twofactorftkexpiry As Integer
Public Property twofactoremailexpiry As Integer
Public Property twofactorsmsexpiry As Integer
Public Property twofactorfacexpiry As Integer
Public Property twofactorftmexpiry As Integer
Public Property peruserbwl As String
Public Property virtualservercount As Integer
Public Property virtualserverhardwareacceleration As String
Public Property wadworkercount As Integer
Public Property wadcsvccscount As Integer
Public Property wadcsvcdbcount As Integer
Public Property wadsourceaffinity As String
Public Property wadmemorychangegranularity As Integer
Public Property logintimestamp As String
Public Property miglogdchildren As Integer
Public Property specialfile23support As String
Public Property loguuidpolicy As String
Public Property loguuidaddress As String
Public Property logsslconnection As String
Public Property arpmaxentry As Integer
Public Property avaffinity As String
Public Property wadaffinity As String
Public Property ipsaffinity As String
Public Property miglogaffinity As String
Public Property urlfilteraffinity As String
Public Property ndpmaxentry As Integer
Public Property brfdbmaxentry As Integer
Public Property maxroutecachesize As Integer
Public Property ipsecasicoffload As String
Public Property ipsecsoftdecasync As String
Public Property deviceidletimeout As Integer
Public Property guidevicelatitude As String
Public Property guidevicelongitude As String
Public Property privatedataencryption As String
Public Property autoauthextensiondevice As String
Public Property guitheme As String
Public Property guidateformat As String
Public Property guidatetimesource As String
Public Property igmpstatelimit As Integer
Public Property cloudcommunication As String
Public Property fecport As Integer
Public Property fortitokencloud As String
End Class
JSON RESPONSE:
{
"http_method":"GET",
"revision":"f38252d751a447443410a7639e54d791",
"results":{
"language":"english",
"gui-ipv6":"disable",
"gui-certificates":"enable",
"gui-custom-language":"disable",
"gui-wireless-opensecurity":"disable",
"gui-display-hostname":"disable",
"gui-fortisandbox-cloud":"disable",
"gui-lines-per-page":50,
"admin-https-ssl-versions":"tlsv1-1 tlsv1-2 tlsv1-3",
"admintimeout":5,
"admin-console-timeout":0,
"ssd-trim-freq":"weekly",
"ssd-trim-hour":1,
"ssd-trim-min":60,
"ssd-trim-weekday":"sunday",
"ssd-trim-date":1,
"admin-concurrent":"enable",
"admin-lockout-threshold":3,
"admin-lockout-duration":60,
"refresh":0,
"interval":5,
"failtime":5,
"daily-restart":"disable",
"restart-time":"00:00",
"radius-port":1812,
"admin-login-max":100,
"remoteauthtimeout":5,
"ldapconntimeout":500,
"batch-cmdb":"enable",
"multi-factor-authentication":"optional",
"ssl-min-proto-version":"TLSv1-2",
"autorun-log-fsck":"disable",
"dst":"enable",
"timezone":"12",
"traffic-priority":"tos",
"traffic-priority-level":"medium",
"anti-replay":"strict",
"send-pmtu-icmp":"enable",
"honor-df":"enable",
"revision-image-auto-backup":"disable",
"revision-backup-on-logout":"disable",
"management-vdom":"root",
"hostname":"test",
"gui-allow-default-hostname":"disable",
"alias":"FortiGate-VM64",
"strong-crypto":"enable",
"ssh-cbc-cipher":"enable",
"ssh-hmac-md5":"enable",
"ssh-kex-sha1":"enable",
"ssh-mac-weak":"enable",
"ssl-static-key-ciphers":"enable",
"snat-route-change":"disable",
"cli-audit-log":"disable",
"dh-params":"2048",
"fds-statistics":"enable",
"fds-statistics-period":60,
"tcp-option":"enable",
"lldp-transmission":"disable",
"lldp-reception":"disable",
"proxy-auth-timeout":10,
"proxy-re-authentication-mode":"session",
"proxy-auth-lifetime":"disable",
"proxy-auth-lifetime-timeout":480,
"sys-perf-log-interval":5,
"check-protocol-header":"loose",
"vip-arp-range":"restricted",
"reset-sessionless-tcp":"disable",
"allow-traffic-redirect":"enable",
"strict-dirty-session-check":"enable",
"tcp-halfclose-timer":120,
"tcp-halfopen-timer":10,
"tcp-timewait-timer":1,
"udp-idle-timer":180,
"block-session-timer":30,
"ip-src-port-range":"1024-25000",
"pre-login-banner":"disable",
"post-login-banner":"disable",
"tftp":"enable",
"av-failopen":"pass",
"av-failopen-session":"disable",
"memory-use-threshold-extreme":95,
"memory-use-threshold-red":88,
"memory-use-threshold-green":82,
"cpu-use-threshold":90,
"check-reset-range":"disable",
"vdom-mode":"no-vdom",
"vdom-admin":"",
"long-vdom-name":"disable",
"admin-port":80,
"admin-sport":8443,
"admin-https-redirect":"enable",
"admin-hsts-max-age":15552000,
"admin-ssh-password":"enable",
"admin-restrict-local":"disable",
"admin-ssh-port":22,
"admin-ssh-grace-time":120,
"admin-ssh-v1":"disable",
"admin-telnet":"enable",
"admin-telnet-port":23,
"default-service-source-port":"1-65535",
"admin-maintainer":"enable",
"admin-server-cert":"self-sign",
"user-server-cert":"Fortinet_Factory",
"admin-https-pki-required":"disable",
"wifi-certificate":"Fortinet_Wifi",
"wifi-ca-certificate":"Fortinet_Wifi_CA",
"auth-http-port":1000,
"auth-https-port":1003,
"auth-keepalive":"disable",
"policy-auth-concurrent":0,
"auth-session-limit":"block-new",
"auth-cert":"Fortinet_Factory",
"clt-cert-req":"disable",
"fortiservice-port":8013,
"cfg-save":"automatic",
"cfg-revert-timeout":600,
"reboot-upon-config-restore":"enable",
"admin-scp":"disable",
"security-rating-result-submission":"enable",
"security-rating-run-on-schedule":"enable",
"wireless-controller":"enable",
"wireless-controller-port":5246,
"fortiextender-data-port":25246,
"fortiextender":"disable",
"fortiextender-vlan-mode":"disable",
"switch-controller":"disable",
"switch-controller-reserved-network":"169.254.0.0 255.255.0.0",
"dnsproxy-worker-count":1,
"url-filter-count":1,
"proxy-worker-count":0,
"scanunit-count":0,
"proxy-kxp-hardware-acceleration":"enable",
"proxy-cipher-hardware-acceleration":"enable",
"fgd-alert-subscription":"",
"ipsec-hmac-offload":"enable",
"ipv6-accept-dad":1,
"ipv6-allow-anycast-probe":"disable",
"csr-ca-attribute":"enable",
"wimax-4g-usb":"disable",
"cert-chain-max":8,
"sslvpn-max-worker-count":0,
"sslvpn-plugin-version-check":"enable",
"two-factor-ftk-expiry":60,
"two-factor-email-expiry":60,
"two-factor-sms-expiry":60,
"two-factor-fac-expiry":60,
"two-factor-ftm-expiry":72,
"per-user-bwl":"disable",
"virtual-server-count":0,
"virtual-server-hardware-acceleration":"enable",
"wad-worker-count":0,
"wad-csvc-cs-count":1,
"wad-csvc-db-count":0,
"wad-source-affinity":"enable",
"wad-memory-change-granularity":10,
"login-timestamp":"disable",
"miglogd-children":0,
"special-file-23-support":"disable",
"log-uuid-policy":"enable",
"log-uuid-address":"disable",
"log-ssl-connection":"disable",
"arp-max-entry":131072,
"av-affinity":"0",
"wad-affinity":"0",
"ips-affinity":"0",
"miglog-affinity":"0",
"url-filter-affinity":"0",
"ndp-max-entry":0,
"br-fdb-max-entry":8192,
"max-route-cache-size":0,
"ipsec-asic-offload":"enable",
"ipsec-soft-dec-async":"disable",
"device-idle-timeout":300,
"gui-device-latitude":"",
"gui-device-longitude":"",
"private-data-encryption":"disable",
"auto-auth-extension-device":"enable",
"gui-theme":"green",
"gui-date-format":"yyyy/MM/dd",
"gui-date-time-source":"system",
"igmp-state-limit":3200,
"cloud-communication":"enable",
"fec-port":50000,
"fortitoken-cloud":"enable"
},
"vdom":"root",
"path":"system",
"name":"global",
"status":"success",
"http_status":200,
"serial":"FGVM2VTM20002896",
"version":"v6.2.5",
"build":1142
}
@gcogneau what is the error message or problem that you get?
If we take for example just this two properties in the result
"language":"english",
"gui-ipv6":"disable",
Language property is populated like it does in the api_global object but gui-ipv6 don't populate the object because the property in the class is guiipv6.
There is no "-" because we can't have "-" in a property.
I have tried to use
<JsonProperty(PropertyName:="gui-ipv6")>
Public Property guiipv6 As String
But had no effect.
So the problem is that all property with "-" don't populate my object with the data...
@gcogneau this is all specific to Json serialization. It has nothing to do with RestClient.Net.
@gcogneau why don't you try Newtonsoft Serialization?
Ok but I was thinking that as you use newtonsoft in your code you had a solution or a way to get property with "-" working. I will check for another solution
@MelbourneDeveloper Yes. Try newtonsoft serialization.