JSON Implementation Example?

(Posted 9 months ago) lavalamp


im a noob when it comes to Json, but want to use it to store my games data, I have a correctly formatted Json file.

But admit have no idea how to implement it in NG, I see it has BRL.Json but it has no examples on how to use it.

Does someone have a simple example file for me on how to load a Json file and apply the data to an object?

Cheers, and Merry Christmas!

    Local temp:TJSON, error:TJSONError , file:TStream
    file = OpenStream:TStream( "incbin::Data/objects.json",True,False)
    ' Populate object with data using Load Method
    ' Loop through
    CloseStream file
(Posted 9 months ago) RonTek commented:

Merry Christmas lavalamp!

I haven't fully explored the default brl.json mod yet, but you can try this from mahan, of course with example.


(Posted 9 months ago) lavalamp commented:

Whoa that looks too complicated for me :(

(Posted 9 months ago) RonTek commented:

Whoa that looks too complicated for me :(

I see. You can also try jannson, this is way more easier.


The example_03.bmx


Framework BaH.Jansson
Import BRL.StandardIO
Import BRL.TextStream

Local text:String = LoadText("menu.json")

Local error:TJSONError

Local json:TJSON = TJSON.Load(text, 0, error)

If Not error Then

    If TJSONObject(json) Then

        For Local j:TJSON = EachIn TJSONObject(json)
            Print j.SaveString(0, 2)

    End If

End If

Reply To Topic (minimum 10 characters)

Please log in to reply