GitHub 레포에 저장된 C#을 사용하여 간단한 json 배열을 디코드하여 값이 포함되어 있는지 확인하고 싶습니다. Newtonsoft json 패키지를 사용하고 있습니다. 이 스레드를 읽었습니다 : Code for decoding/encoding a modified base64 URL,하지만 솔루션을 구현할 수없는 것 같습니다. 다음과 같은 오류가 발생합니다.URL에서 보낸 Base64 디코드 json 배열
System.FormatException: 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
그러나 나는 또한 코드에 어떤 변화가 있다고 생각합니다.
var value = "somestring";
var encodedTopicTypeURL ="https://api.github.com/repos/org/repo1/contents/sample.json";
string decodedTopicTypeURL;
byte[] buffer = Convert.FromBase64String(encodedTopicTypeURL);
decodedTopicTypeURL = Encoding.UTF8.GetString(buffer);
using (var webClient = new System.Net.WebClient())
{
var topicTypeJson = webClient.DownloadString(decodedTopicTypeURL);
JArray validTopicTypes = JArray.Parse(topicTypeJson);
if (!validTopicTypes.Contains(value))
{
Logger.LogError($"Value not found");
}
JSON 배열 :
[
"string1",
"string2",
"string3",
"string4",
]
예, 내가 GitHub의에서 JSON 파일의 URL에서 Base64로 표현을 참조 디코딩/Base64 인코딩 놀러 this 사이트를 사용할 수 있습니다. 문자열이 아니라고 말하면, 값을 확인하기 위해 키에 액세스하기 위해 JSON을 올바르게 디코딩하는 방법을 알고 싶습니다. 이 작업을 수행하는 방법을 보여주는 URL이 있거나 위에 나와있는 질문 및 코드를 기반으로하는 코드 샘플이있는 경우 – DBS