1. Import the Litjson into the project;
2. Build a script below, not hanging on the game object;
3. Create a new script to hang on the camera.
1 usingSystem.Collections;2 usingSystem.Collections.Generic;3 usingUnityengine;4 5 Public classAnalyzejsontest:monobehaviour6 {7 stringSSS;8 voidStart ()9 {TenSSS = One "{' desc ': ' hahaha ', ' status ': ' + ', ' data ': {' Wendu ': ' A ', ' Ganmao ': ' The relative to today will be a substantial cooling, prone to colds, please pay attention to appropriate increase clothing, strengthen self-protection to avoid colds. ', ' forecast ': [{' Fengxiang ': ' North Wind ', ' Fengli ': ' 3-4 ', ' High ': ' Hot 27 ℃ ', ' type ': ' Moderate rain ', ' low ': ' Cool 19 ℃ ', ' Date ': ' 6th Friday '} , {' Fengxiang ': ' North Wind ', ' fengli ': ' Breeze level ', ' High ': ' Hot 23 ℃ ', ' type ': ' Heavy rain ', ' low ': ' Lo 17 ℃ ', ' Date ': ' 7th Saturday '}, {' Fengxiang ': ' North Wind ', ' fengli ': ' Breeze level ', ' High ': ' Hot 26 ℃ ', ' type ': ' Light rain ', ' low ': ' Cold 17 ℃ ', ' Date ': ' 8th Sunday '}, {' Fengxiang ': ' South Wind ', ' Fengli ': ' Breeze ', ' high ': ' Hot 27 ℃ ', ' type ': ' Cloudy ', ' low ': ' Cold 15 ℃ ', ' Date ': ' 9th ', ' {' Fengxiang ': ' South Wind ', ' fengli ': ' Breeze level ', ' high ': ' High temperature 29 ℃ ', ' type ': ' Cloudy ', ' low ': ' Cool 16 ℃ ', ' Date ': ' 10th Tuesday '}], ' Yesterday ': {' fl ': ' Breeze ', ' FX ': ' North Wind ', ' High ': ' Hot 33 ℃ ', ' t Ype ': ' Yin ', ' low ': ' Lo ' 22 ℃ ', ' Date ': ' 5th ', ' AQI ': ' + ', ' City ': ' Chengdu ' }"; A - Analyzejson (); - } the voidAnalyzejson () - { -Litjson.jsondata Jsondata =Readjson.analysejson (SSS); - //string S1 = jsondata["desc"][0]. ToString (); The wrong idea + - stringS1 = jsondata["desc"]. ToString (); + stringS2 = jsondata[0]. ToString (); APrint"S1 + s2:"+ S1 +"\ t"+S2); at //hahaha hahaha - - stringS3 = jsondata[1]. ToString (); -Print"S3:"+S3); - // + - in stringS4 = jsondata["Data"]["Wendu"]. ToString (); -Print"S4:"+S4); to // - + - stringS5 = jsondata["Data"][1]. ToString (); thePrint"S5:"+S5); * //compared to today will be a substantial cooling, prone to colds, please pay attention to appropriate increase clothing, strengthen self-protection to avoid colds. $ Panax Notoginseng stringS6 = jsondata[2][2][2][5]. ToString (); -Print"S6:"+S6); the //8th Sunday + A stringS7 = jsondata[2][2][4][4]. ToString (); thePrint"S7:"+S7); + //Lo 16 ℃ - } $ $ /* - - {' desc ': ' hahaha ', the ' status ': +, - ' data ':Wuyi {' Wendu ': ' A ', the ' Ganmao ': ' Compared to today there will be a substantial cooling, prone to colds, please pay attention to appropriate increase clothing, strengthen self-protection to avoid colds. ', - ' forecast ': Wu [{' Fengxiang ': ' North Wind ', ' fengli ': ' Level 3-4 ', ' High ': ' Hot 27 ℃ ', ' type ': ' Moderate rain ', ' low ': ' Cryogenic 19 ℃ ', ' Date ': ' Friday, 6th ' - }, About {' Fengxiang ': ' North Wind ', ' fengli ': ' Breeze level ', ' High ': ' Hot 23 ℃ ', ' type ': ' Heavy rain ', ' low ': ' Lo 17 ℃ ', ' Date ': ' 7 Day Saturday ' $ }, - {' Fengxiang ': ' North Wind ', ' fengli ': ' Breeze level ', ' High ': ' Hot 26 ℃ ', ' type ': ' Drizzle ', ' low ': ' Lo 17 ℃ ', ' Date ': ' 8 Day Sunday ' - }, - {' Fengxiang ': ' South Wind ', ' fengli ': ' Breeze level ', ' High ': ' Hot 27 ℃ ', ' type ': ' Cloudy ', ' low ': ' Cool 15 ℃ ', ' Date ': ' 9 Day Monday ' A }, + {' Fengxiang ': ' South Wind ', ' fengli ': ' Breeze level ', ' High ': ' Hot 29 ℃ ', ' type ': ' Cloudy ', ' low ': ' Cool 16 ℃ ', ' Date ': ' 1 0 days Tuesday the } - ], $ ' Yesterday ': the {' fl ': ' Breeze ', ' FX ': ' North Wind ', ' High ': ' Hot 33 ℃ ', ' type ': ' Yin ', ' low ': ' Cold 22 ℃ ', ' Date ': ' 5th Thursday ' the }, the ' aqi ': ' + ', the ' city ': ' Chengdu ' - } in } the */ the}
4. Change the data in the 3 script yourself and smash it.
JSON parsing JSON