본문 바로가기

JSON9

Flutter 플러터 앱에 JSON 자산을 로드하는 방법은 무엇인가요?, How to load JSON assets into a Flutter App? 질문 내 Flutter 앱에 JSON 자산을로드하는 방법은 무엇입니까? 내 pubspec.yaml 파일은 다음과 같습니다: assets: - assets/data.json 데이터를로드하려고하면 항상 막힙니다. 시도해 봤습니다: final json = JSON.decode( DefaultAssetBundle.of(context).loadString("assets/data.json") ); 하지만 오류가 발생합니다: 인수 형식 'Future'은(는) 'String' 매개 변수 형식에 할당할 수 없습니다. 답변 다음을 시도해보세요 : String data = await DefaultAssetBundle.of(context).loadString("assets/data.json"); final j.. 2023. 6. 24.
Flutter 처리되지 않은 예외: 'InternalLinkedHashMap<String, dynamic>'은(는) 'List<dynamic>' 유형의 하위 유형이 아닙니다., Unhandled Exception: InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic> 질문 나는 서버에서 JSON 응답을 가져와 콘솔에 출력하려고 노력하고 있습니다. Future login() async { var response = await http.get( Uri.encodeFull("https://etrans.herokuapp.com/test/2"), headers: {"Accept": "application/json"}); this.setState(() { data = json.decode(response.body); }); print(data[0].name); return "Success!"; } Unhandled Exception: type '_InternalLinkedHashMap' is not a subtype of type 'List 이유는 무엇일까요? 답변 다음은 잘못.. 2023. 6. 1.
Flutter 플러터에서 json으로부터 객체 목록을 역직렬화하는 방법, How to Deserialize a list of objects from json in flutter 질문 저는 json serialization을 위해 dart 패키지 json_serializable을 사용하고 있습니다. 플러터 문서를 살펴보면 다음과 같이 단일 객체를 역직렬화하는 방법이 나와 있습니다: Future fetchPost() async { final response = await http.get('https://jsonplaceholder.typicode.com/posts/1'); if (response.statusCode == 200) { // 서버 호출이 성공하면 JSON을 파싱합니다 return Post.fromJson(json.decode(response.body)); } else { // 호출이 실패하면 오류를 throw합니다. throw Exception('Failed to lo.. 2023. 5. 29.
Python 왜 파이썬은 이 JSON 데이터를 파싱하지 못하나요? [닫힘], Why can't Python parse this JSON data? [closed] 질문 이 파일에 이 JSON이 있습니다: { "maps": [ { "id": "blabla", "iscategorical": "0" }, { "id": "blabla", "iscategorical": "0" } ], "masks": [ "id": "valore" ], "om_points": "value", "parameters": [ "id": "valore" ] } 모든 JSON 데이터를 출력하기 위해 이 스크립트를 작성했습니다: import json from pprint import pprint with open('data.json') as f: data = json.load(f) pprint(data) 하지만 이 프로그램은 예외를 발생시킵니다: Traceback (most recent call la.. 2023. 5. 23.