Hjælp til at hente flere variabler ud
Jeg har et script, som arnce_v har skrevet, men jeg havde overset at datafilen indeholdt flere lag af data, så derfor vil jeg lige høre hvordan jeg bedst henter det hele ud af filen.Den er konstrueret som nedenstående:
**** start object ****
field name = NativeClass, field value = Class'/Script/FactoryGame.FGBuildable'
field name = Classes, field value = [
{
"ClassName": "Build_WorkBench_C",
"mOccupiedText": "Craftbench is occupied!",
"mDisplayName": "Craft Bench",
"mDescription": "Allows you to manually craft a large range of different parts. \r\nThese parts can then be used in construction of different factory buildings, vehicles and equipment.",
"MaxRenderDistance": "-1.000000",
"mHighlightVector": "(X=0.000000,Y=0.000000,Z=0.000000)",
"mAllowColoring": "True",
"mSkipBuildEffect": "False",
"mBuildEffectSpeed": "0.000000",
"mForceNetUpdateOnRegisterPlayer": "True",
"mToggleDormancyOnInteraction": "False",
"mShouldShowHighlight": "False",
"mShouldShowAttachmentPointVisuals": "False",
"mCreateClearanceMeshRepresentation": "True",
"mAttachmentPoints": "",
"mInteractingPlayers": "",
"mIsUseable": "True",
"mHideOnBuildEffectStart": "False",
"mShouldModifyWorldGrid": "True"
},
{
"ClassName": "Build_Workshop_C",
"mOccupiedText": "Equipment Workshop is occupied!",
"mDisplayName": "Equipment Workshop",
"mDescription": "Used to manually craft equipment.",
"MaxRenderDistance": "-1.000000",
"mHighlightVector": "(X=0.000000,Y=0.000000,Z=0.000000)",
"mAllowColoring": "True",
"mSkipBuildEffect": "False",
"mBuildEffectSpeed": "0.000000",
"mForceNetUpdateOnRegisterPlayer": "False",
"mToggleDormancyOnInteraction": "False",
"mShouldShowHighlight": "False",
"mShouldShowAttachmentPointVisuals": "False",
"mCreateClearanceMeshRepresentation": "True",
"mAttachmentPoints": "",
"mInteractingPlayers": "",
"mIsUseable": "True",
"mHideOnBuildEffectStart": "False",
"mShouldModifyWorldGrid": "True"
}, ....
og slutter så af med ]
men den henter kun værdierne for NativeClass og Classes
Jeg mangler værdierne efter [.
Jeg kan ikke helt gennemskue det måske fordi jeg er ny til Json.
Koden i programmet ser sådanne ud :
Imports System
Imports System.Collections.Generic
Imports System.IO
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Namespace E
Public Class Program
Public Shared Sub Main(args As String())
Dim all As JArray = DirectCast(JsonConvert.DeserializeObject(File.ReadAllText("Docs.json")), JArray)
For Each one As JObject In all
Console.WriteLine("**** start object ****")
For Each f As KeyValuePair(Of String, JToken) In one
Console.WriteLine("field name = {0}, field value = {1}", f.Key, f.Value.ToString())
Next
Next
Console.ReadKey()
End Sub
End Class
End Namespace