The input is not a valid Base-64 string how to solve

I have the following code: var test = "eyJhbGciOiJSUzI1NiIsImtpZCI6IlRlc3RDZXJ0IiwidHlwIjoiYXQrand0In0"; var base64EncodedBytes = System.Convert.FromBase64String(test); var hidenString = System.Text.Encoding.UTF8.GetString(base64EncodedBytes); and I get the following error: ‘The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.’ Any help? how do… Read More The input is not a valid Base-64 string how to solve

How to decode a JSON Dictionary?

I am able to decode straight forward json responses but as the JSON gets more nested, I’m struggling. To decode JSON that looks like this: [ { "id": "string", "username": "string", "firstName": "string", "lastName": "string", "fullName": "string", "email": "string", "isInActivity": true, "activeEventId": "string", "initials": "string" } ] My struct is: struct FriendsStruct: Decodable, Hashable {… Read More How to decode a JSON Dictionary?

For Loop with json decode data error requires 'People' to conform to 'Sequence'

I am new to swift . I created simple playground and added the file with extension json into playground . I am trying to decode the result and print the ID by using for loop but , I am getting following error .. For-in loop requires ‘People.Type’ to conform to ‘Sequence’ Here is my json… Read More For Loop with json decode data error requires 'People' to conform to 'Sequence'

continue loop even if one host is not available

import time import paramiko import sys from getpass import getpass #First Unifi AP IP Address firstip=3 fistdigits = ‘10.0.0.’ #how can we prevent from crashing if 10.0.0.19 is not an available device while firstip<=100: host= f'{fistdigits}{firstip}’ #first one will be 10.0.0.3 then 10.0.0.4 etc username="username" password="password" session= paramiko.SSHClient() session.set_missing_host_key_policy(paramiko.AutoAddPolicy()) session.connect(hostname=host, username=username, password=password) #upgradeurl="https://dl.ui.com/unifi/firmware/U7PG2/4.3.13.11253/BZ.qca956x.v4.3.13.11253.200430.1420.bin&quot; #stdin, stdout,… Read More continue loop even if one host is not available

Convert "weird" strings to normal python strings

Context: I’m trying to convert characters like these: 𝐁𝐔𝐈𝐋𝐃𝐈𝐍𝐆 𝙎𝙥𝙚𝙚𝙙𝙮 𝕋𝕌𝔼𝕊𝔻𝔸𝕐 𝕤𝕡𝕒𝕘𝕙𝕖𝕥𝕥𝕚 To normal python strings (speedy, building, tuesday, etc) and save them into a new dataframe to be exported into a new excel file. For example, the charcter 𝕒 (U+1D552) should be converted to a (U+00AA). I’m reading each string from an excel file… Read More Convert "weird" strings to normal python strings

Parse JSON into nested structs

type APIResponse struct { Results []Result `json:"results,omitempty"` Paging Paging } type Result struct { Id string `json:"id"`, Name string `json:"name"`, } type Paging struct { Count int `json:"count"` Previous string `json:"previous"` Next string `json:"next"` } func Get(ctx context.Context) APIResponse[T] { results := APIResponse{} rc, Err := r.doRequest(ctx, req) if rc != nil { defer rc.Close()… Read More Parse JSON into nested structs