꿀먹는돼지
꿀돼지블로그
꿀먹는돼지
전체 방문자
오늘
어제
  • 분류 전체보기 (156)
    • 여행 (2)
    • TODAY (1)
    • 주식 (1)
    • DEV (58)
      • Server (2)
      • SpringFramework (5)
      • DB (0)
      • Unity (44)
      • 그냥 알고리즘공부 (2)
      • JAVA (2)
    • Aseprite (1)
    • OLD개발이야기 (63)
      • IT 공부 (6)
      • 알고리즘 공부 (6)
      • 개발관련 글 (3)
      • C++ (5)
      • C# (0)
      • Qt (8)
      • bigdata (2)
      • Python-mysql (12)
      • html (2)
      • python (1)
      • Android Studio (6)
      • 자바스크립트 (2)
      • 포트폴리오 (0)
      • 작업 (0)
      • 기타작업 (2)
    • IT Tools (1)
    • 기타 (12)

블로그 메뉴

  • 홈
  • 방명록
  • 태그
  • 미디어로그
  • 위치로그

공지사항

인기 글

태그

  • 모바일
  • 1인개발
  • 유니티
  • 인디게임
  • 마녀 게임
  • Unity
  • 마녀
  • 클리커
  • mysql
  • honyepig
  • 육성게임
  • PYTHON
  • myql#외부접속
  • 위치캐슬
  • database
  • 육성
  • 게임
  • 마녀육성
  • 도트
  • 도트게임

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
꿀먹는돼지

꿀돼지블로그

DEV/Unity

[solved] UnityWebRequest Get noneArray Type error

2020. 12. 19. 22:42

대강 

{"code":0,"results":{"contents":"abcd”,"contents":"abcd”,"contents":"abcd”...}}

형식으로 데이터가 들어올 것을 감안하여

1
2
3
4
5
6
7
8
9
10
11
12
13
public class ServerData {
 
    public string code;
 
    public Data[] results;
 
}
 
public class Data{
 
  public string content;
 
}
cs

 

로 만들었는데 

중간에 데이터가 1개인 경우가 있어서 한참 고생했다. 

 

-> noneArray Type;;;

Extra details: the issue ONLY happens if the target object where the json is deserialized has a field of array type and the json contains that field with a non-array type.

If it's the other way around and the target object contains a non-array type field and that field in the json has a different type (numeric, array, etc) it will not crash and will be silently ignored.

이게 떠서 한참 고생했다.겨우 찾은 답은 배열 문제 였음.

{"code":0,"results":{"contents":"abcd”}}

해당건은 이렇게 들어왔기 때문..

result가 [] 가 아니었음.. 

 

 

참고 URL

https://issuetracker.unity3d.com/issues/unexpected-node-type-dot-error-is-thrown-and-no-exception-is-caught-when-using-jsonutility-dot-fromjsonoverwrite-function

 

 

내 스크립트 예시 

1
2
3
4
5
6
7
8
9
10
11
12
   GetMessage() {
        UnityWebRequest www = UnityWebRequest.Get("URL");
        yield return www.SendWebRequest();
        if (www.isNetworkError || www.isHttpError) {
            Debug.Log(www.error);
        } else {
            // Show results as text - Debug.Log(www.downloadHandler.text);
            ServerData ServerData1= JsonUtility.FromJson<ServerData>(www.downloadHandler.text);
            obj.SetMsg(ServerData1.results[0].contents);
        }
    }
 
Colored by Color Scripter
cs

 

'DEV > Unity' 카테고리의 다른 글

[solved] Unity Scroll View position initialize  (1) 2020.12.19
Unity ads error Banner fail  (0) 2020.12.19
NullReferenceException: Object reference not set to an instance of an objectUnityEditor.Graphs.Edge.WakeUp ()  (0) 2020.05.17
unity Dotween DOMOVE CALLBACK  (0) 2020.05.05
유니티 터치 관련  (0) 2017.08.08
    'DEV/Unity' 카테고리의 다른 글
    • [solved] Unity Scroll View position initialize
    • Unity ads error Banner fail
    • NullReferenceException: Object reference not set to an instance of an objectUnityEditor.Graphs.Edge.WakeUp ()
    • unity Dotween DOMOVE CALLBACK
    꿀먹는돼지
    꿀먹는돼지
    꿀꿀

    티스토리툴바