Results 1 to 28 of 28

Thread: [RESOLVED] JSON node retrive info

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Resolved [RESOLVED] JSON node retrive info

    How to retrieve all info from json node in attached file?
    Tks.

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: JSON node retrive info

    There are plenty of JSON parsers and even combined parser/serializers here in the CodeBank and elsewhere. There are even a few "SAX" style parsers for rapidly processing JSON input when they are huge or you have tons of JSON docs to process.

  3. #3
    Hyperactive Member
    Join Date
    Nov 2011
    Posts
    498

    Re: JSON node retrive info

    this should get you started.
    create a new project and add a command button to the form 'Command1'

    download the mdjson.bas module https://gist.github.com/wqweto/e92dc...a91b053b9510c9

    add to the project.

    now add the 2 items below to the main form1. save the project to a folder.
    place JOSON.txt in the same folder.

    now run and click the button.


    Code:
    Private Sub Command1_Click()
    
        Dim Result As String
        Result = ReadTextFile(App.Path & "\JOSON.txt")
    
    
        Dim p As Object
    
        Set p = mdJson.JsonParseObject(Result)
    
        If p Is Nothing Then
    
            Exit Sub
        End If
    
        VSFActions.Rows = 0
    
        Debug.Print JsonValue(p, "data/cf")
        Debug.Print JsonValue(p, "data/denominazione")
        Debug.Print JsonValue(p, "data/dettaglio/rea")
    
        Debug.Print JsonValue(p, "data/gps/coordinates").Count
        Debug.Print JsonValue(p, "data/gps/coordinates/0")
        Debug.Print JsonValue(p, "data/gps/coordinates/1")
    
    
    End Sub
    Code:
    Public Function ReadTextFile(ByVal sFileName As String) As String
        Dim Handle As Integer
        ' ensure that the file exists
        If Len(Dir$(sFileName)) = 0 Then
            Err.Raise 53  ' File not found
        End If
        ' open in binary mode
        Handle = FreeFile
        Open sFileName$ For Binary As #Handle
        ' read the string and close the file
        ReadTextFile = Space$(LOF(Handle))
        Get #Handle, , ReadTextFile
        Close #Handle
    End Function
    also a good tool to have is the Mitec Json Viewer. its free for personal use.

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: JSON node retrive info

    Looks like a broken implementation.

    Only the \ is excluded as property name character, using / here is problematic. The / can be escaped but is not required to be.

  5. #5
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: JSON node retrive info

    Quote Originally Posted by dilettante View Post
    Looks like a broken implementation.

    Only the \ is excluded as property name character, using / here is problematic. The / can be escaped but is not required to be.
    Nothing broken here. Previous time you tried to spread this FUD you got me worried and I had to check everything is implemented ok.

    Forward slash should not be escaped, no one does this anymore.

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: JSON node retrive info

    But "data/gps" is a valid JSON property name. If you try to use "/" for path navigation why wouldn't it choke on that?

    See: Valid Key Names in JSON
    Last edited by dilettante; May 23rd, 2023 at 05:35 PM.

  7. #7
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: JSON node retrive info

    You can use JSON Path with JsonValue accessor property too i.e. JsonValue(p, "$.data/gps") or JsonValue(p, "$['data/gps']").

    Using forward slash in keys (property names) is possible but not recommended. How do you retrieve "data/gps" tag in XML? Is XML broken?

    Obviously the shorthand syntax is inspired by XPath i.e. someone used to working with XML can feel comfortable querying JSON data.

    Also, JsonParse/JsonDump helpers do not choke on forward slash i.e. "data/gps" for key name is parsed ok.

    cheers,
    </wqw>

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: JSON node retrive info

    Quote Originally Posted by k_zeon View Post
    this should get you started.
    create a new project and add a command button to the form 'Command1'

    download the mdjson.bas module https://gist.github.com/wqweto/e92dc...a91b053b9510c9

    add to the project.

    now add the 2 items below to the main form1. save the project to a folder.
    place JOSON.txt in the same folder.

    now run and click the button.


    Code:
    Private Sub Command1_Click()
    
        Dim Result As String
        Result = ReadTextFile(App.Path & "\JOSON.txt")
    
    
        Dim p As Object
    
        Set p = mdJson.JsonParseObject(Result)
    
        If p Is Nothing Then
    
            Exit Sub
        End If
    
        VSFActions.Rows = 0
    
        Debug.Print JsonValue(p, "data/cf")
        Debug.Print JsonValue(p, "data/denominazione")
        Debug.Print JsonValue(p, "data/dettaglio/rea")
    
        Debug.Print JsonValue(p, "data/gps/coordinates").Count
        Debug.Print JsonValue(p, "data/gps/coordinates/0")
        Debug.Print JsonValue(p, "data/gps/coordinates/1")
    
    
    End Sub
    Code:
    Public Function ReadTextFile(ByVal sFileName As String) As String
        Dim Handle As Integer
        ' ensure that the file exists
        If Len(Dir$(sFileName)) = 0 Then
            Err.Raise 53  ' File not found
        End If
        ' open in binary mode
        Handle = FreeFile
        Open sFileName$ For Binary As #Handle
        ' read the string and close the file
        ReadTextFile = Space$(LOF(Handle))
        Get #Handle, , ReadTextFile
        Close #Handle
    End Function
    also a good tool to have is the Mitec Json Viewer. its free for personal use.
    NO IDEA...

    see when i attach the bas module
    Attached Images Attached Images  

  9. #9
    Hyperactive Member
    Join Date
    Nov 2011
    Posts
    498

    Re: JSON node retrive info

    Quote Originally Posted by luca90 View Post
    NO IDEA...

    see when i attach the bas module
    just in case you copied bad info. try this direct link to the raw data
    https://gist.githubusercontent.com/w...eed/mdJson.bas

    now add a new bas module and name it mdjson

    now copy the contents of the above and paste into the module mdjson

    pls advise , if not i can post a link to the example i made and tested.
    Last edited by k_zeon; May 24th, 2023 at 11:29 AM.

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: JSON node retrive info

    Quote Originally Posted by k_zeon View Post
    just in case you copied bad info. try this direct link to the raw data
    https://gist.githubusercontent.com/w...eed/mdJson.bas

    now add a new bas module and name it mdjson

    now copy the contents of the above and paste into the module mdjson

    pls advise , if not i can post a link to the example i made and tested.
    isn't it easier if you send me yours than the test you did?
    tks.

  11. #11
    Hyperactive Member
    Join Date
    Nov 2011
    Posts
    498

    Re: JSON node retrive info

    Quote Originally Posted by luca90 View Post
    isn't it easier if you send me yours than the test you did?
    tks.
    i have created a small example

    https://www.dropbox.com/s/ot8zbztionyp1sc/test.zip?dl=0

    let me know if you cannot download as i dont often upload stuff

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: JSON node retrive info

    Quote Originally Posted by k_zeon View Post
    i have created a small example

    https://www.dropbox.com/s/ot8zbztionyp1sc/test.zip?dl=0

    let me know if you cannot download as i dont often upload stuff
    WOW....

    I comment the red lines, and it work perfect...

    bohhhhh.....

    tks in other case for code.

  13. #13
    Hyperactive Member
    Join Date
    Nov 2011
    Posts
    498

    Re: JSON node retrive info

    Quote Originally Posted by luca90 View Post
    WOW....

    I comment the red lines, and it work perfect...

    bohhhhh.....

    tks in other case for code.
    you shouldn't need to comment out the red lines. i didn't

  14. #14
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: JSON node retrive info

    it's by :Set Js = New ScriptControl +json2.js
    It is important to note that json key names are also case sensitive

    Code:
    Dim Json As New XiaoYaoJson2
    
    Dim JsonStr As String
    JsonStr = "{'abc':[""门头门柱"",""气窗花枝"",""主门款式""]}"
    
    JsonStr = "{'abc':[""item1"",""item2"",""item3""]}"
    Json.PutJsonStr JsonStr
    
    Dim Arr1
    
     Arr1 = Json.GetValuesArr("abc")
    'debug.print TypeName(Arr1)
    Dim a
    For Each a In Arr1
        Debug.Print a
    Next
    'JSGBOX Json.GetValue("typeof ")
    Json.SetValue "Username", "tom"
    Json.SetValue "Username", "tom"
    
    
    Debug.Print TypeName(Json.JsonObj)
    Debug.Print TypeName(Json.GetObjctItem(Json.JsonObj, "Username"))
    Debug.Print TypeName(Json.GetValue("Username"))
    Debug.Print TypeName(Json.GetValue("abc"))
    
    Debug.Print Json.GetValue("Username")
    Debug.Print Json.IsArryObject("abc")
    Debug.Print Json.IsArryObject("Username")
    
    Debug.Print Json.GetTypeName("Username")
    Debug.Print Json.GetTypeName("abc")
    Debug.Print Json.IsString("Username")
    
    Json.Js.Eval ("JsonObj.UserInfo={'age':19,'discipline':'computer'}")
    
     Json.SetValue "UserInfo2", "{'age':19,'discipline':'computer'}", False
     
     
    Debug.Print Json.GetTypeName("UserInfo")
    
    
    Debug.Print Json.GetJsonObjectStrFormat
    Debug.Print Json.GetJsonObjectStrFormat("UserInfo")
    Dim S() As String
    S = Json.GetValuesString("")
    Debug.Print Join(S, vbCrLf)
    
    S = Json.GetValuesString("UserInfo2")
    Debug.Print Join(S, vbCrLf)
    
    S = Json.GetKeysString("UserInfo2")
    Debug.Print Join(S, vbCrLf)
    
    S = Json.GetKeysString("")
    Debug.Print Join(S, vbCrLf)
    ---------------------------
    jsontest
    ---------------------------
    {

    "abc": [

    "item1",

    "item2",

    "item3"

    ],

    "Username": "tom",

    "UserInfo": {

    "age": 19,

    "discipline": "computer"

    },

    "UserInfo2": {

    "age": 19,

    "discipline": "computer"

    }

    }
    ---------------------------
    Last edited by xiaoyao; May 24th, 2023 at 08:25 PM.

  15. #15
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: JSON node retrive info

    Code:
    Dim Json As New XiaoYaoJson2
    
    Dim JsonStr As String
     
    JsonStr = "{'Key1':'test1','abc':[""item1"",""item2"",""item3""]}"
    Json.PutJsonStr JsonStr
    
    Debug.Print Json.Item("Key1")
    
    Debug.Print Json("key1")
    Json("Key1") = "new Value1"
    Json("Key2") = "new Value2"
    
    Json("key2") = "new Value3"
    
    Json.JsonObj.Key1 = "new Value4"
    'obj.item can be operated directly if only the key name exists, and is case sensitive
    
    Debug.Print Json.GetJsonObjectStrFormat

    {
    "Key1": "new Value4",
    "abc": [
    "item1",
    "item2",
    "item3"
    ],
    "Key2": "new Value2",
    "key2": "new Value3"
    }

  16. #16
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: JSON node retrive info

    Code:
    var JsonObj={
        "Key1": "new Value4",
        "abc": [
            "item1",
            "item2",
            "item3"
        ],
        "Key2": "new Value2",
        "key2": "new Value3",
        "Key3": {
            "age": 19,
            "discipline": "computer"
        },
        "data/gps": "Value5",
        "Key4": {
            "age": 20,
            "discipline": "computer2"
        }
    }
    alert( JsonObj['data/gps'] )
    Special key names do this

  17. #17
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: JSON node retrive info

    why it's err?

    Code:
     Dim p As Object, JsonStr As String
    JsonStr = "{'abc':[""item1"",""item2"",""item3""] ,'KKK':333 ,'data':{'cf':'cf value','denominazione':'value2'}   }"
    
        Set p = JsonParseObject(JsonStr)
    
        If p Is Nothing Then
            Exit Sub
        End If
     
    
        Debug.Print JsonValue(p, "data/cf")
        Debug.Print JsonValue(p, "data/denominazione")

  18. #18
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,056

    Re: JSON node retrive info

    the crusty old ms script control can be used as well

    Code:
    Private Sub Form_Load()
        
        Dim jsonstr As String
        
        jsonstr = "{'abc':[""item1"",""item2"",""item3""] ,'KKK':333 ,'data':{'cf':'cf value','denominazione':'value2'}   }"
    
        If Not LoadJson(jsonstr) Then Exit Sub
        
        Debug.Print sc.Eval("json.data.cf")
        Debug.Print sc.Eval("json.data.denominazione")
    
    End Sub
    
    Function LoadJson(ByVal JSON As String) As Boolean
        
        On Error Resume Next
        sc.Reset
        JSON = "var None=''; var True=1; var False=0; var json = " & JSON 
        sc.AddCode JSON
        LoadJson = (Err.Number = 0)
        
    End Function
    Last edited by dz32; May 25th, 2023 at 09:26 AM.

  19. #19

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: JSON node retrive info

    Quote Originally Posted by dz32 View Post
    the crusty old ms script control can be used as well

    Code:
    Private Sub Form_Load()
        
        Dim jsonstr As String
        
        jsonstr = "{'abc':[""item1"",""item2"",""item3""] ,'KKK':333 ,'data':{'cf':'cf value','denominazione':'value2'}   }"
    
        If Not LoadJson(jsonstr) Then Exit Sub
        
        Debug.Print sc.Eval("json.data.cf")
        Debug.Print sc.Eval("json.data.denominazione")
    
    End Sub
    
    Function LoadJson(ByVal JSON As String) As Boolean
        
        On Error Resume Next
        sc.Reset
        JSON = "var None=''; var True=1; var False=0; var json = " & JSON 
        sc.AddCode JSON
        LoadJson = (Err.Number = 0)
        
    End Function
    Hi bro...
    i have a difficult to parse this file!
    not have the same structure of first file.
    sorry me and tks for patience.
    Attached Files Attached Files

  20. #20
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,056

    Re: JSON node retrive info

    your data is not a single json blob. it is many different ones each on its own line.

    Code:
    {"type":"Feature","properties":{"hash":"f86c81a77c8ab0be","number":"144","street":"Via dell'Isola Farnese","unit":"","city":"ROMA","district":"ROMA","region":"LAZIO","postcode":"00123","id":"13800020324848"},"geometry":{"type":"Point","coordinates":[12.388608,42.018851]}}
    {"type":"Feature","properties":{"hash":"d222b720a5d7e71a","number":"20","street":"Via delle Mimose","unit":"","city":"ROCCA PRIORA","district":"ROMA","region":"LAZIO","postcode":"00040","id":"13800020805729"},"geometry":{"type":"Point","coordinates":[12.745922,41.786285]}}
    
    Its often handy to send these through js beautifier to see their structure easily... 
    https://beautifier.io/
    
    {
    	"type": "Feature",
    	"properties": {
    		"hash": "0471ff336a327263",
    		"number": "23",
    		"street": "Via 4 Aprile",
    		"unit": "",
    		"city": "ARAGONA",
    		"district": "AGRIGENTO",
    		"region": "SICILIA",
    		"postcode": "92021",
    		"id": "13800023883257"
    	},
    	"geometry": {
    		"type": "Point",
    		"coordinates": [13.616626, 37.405944]
    	}
    }
    You have to parse each element individually.

    Code:
    Private Sub Form_Load()
        
        Dim jsonFile As String, line() As String, i As Long, errs As Long
        
        sc.UseSafeSubset = True
        sc.Language = "JScript"
        
        jsonFile = ReadFile(app.path & "\test_json.txt")
        line = Split(jsonFile, vbCrLf)
        
        For i = 0 To UBound(line)
            If Len(line(i)) > 0 Then
                If Not LoadJson(line(i)) Then
                    Debug.Print "Error on element: " & i & " Error Line:" & sc.Error.line & ": " & sc.Error.Description
                    errs = errs + 1
                Else
                    Debug.Print i & ") " & sc.Eval("json.properties.city")
                End If
            End If
        Next
        
        Debug.Print "Errors: " & errs
        
    End Sub
    
    Function LoadJson(ByVal JSON As String) As Boolean
        
        On Error Resume Next
        sc.Reset
        JSON = "var None=''; var True=1; var False=0; var json = " & JSON
        sc.AddCode JSON
        LoadJson = (Err.Number = 0)
        
    End Function
     
    Function ReadFile(filename)
      Dim f, temp
      f = FreeFile
      temp = ""
       Open filename For Binary As #f        ' Open file.(can be text or image)
         temp = Input(FileLen(filename), #f) ' Get entire Files data
       Close #f
       ReadFile = temp
    End Function
    Last edited by dz32; May 28th, 2023 at 06:24 AM.

  21. #21

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: JSON node retrive info

    Quote Originally Posted by dz32 View Post
    your data is not a single json blob. it is many different ones each on its own line.

    Code:
    {"type":"Feature","properties":{"hash":"f86c81a77c8ab0be","number":"144","street":"Via dell'Isola Farnese","unit":"","city":"ROMA","district":"ROMA","region":"LAZIO","postcode":"00123","id":"13800020324848"},"geometry":{"type":"Point","coordinates":[12.388608,42.018851]}}
    {"type":"Feature","properties":{"hash":"d222b720a5d7e71a","number":"20","street":"Via delle Mimose","unit":"","city":"ROCCA PRIORA","district":"ROMA","region":"LAZIO","postcode":"00040","id":"13800020805729"},"geometry":{"type":"Point","coordinates":[12.745922,41.786285]}}
    
    Its often handy to send these through js beautifier to see their structure easily... 
    https://beautifier.io/
    
    {
    	"type": "Feature",
    	"properties": {
    		"hash": "0471ff336a327263",
    		"number": "23",
    		"street": "Via 4 Aprile",
    		"unit": "",
    		"city": "ARAGONA",
    		"district": "AGRIGENTO",
    		"region": "SICILIA",
    		"postcode": "92021",
    		"id": "13800023883257"
    	},
    	"geometry": {
    		"type": "Point",
    		"coordinates": [13.616626, 37.405944]
    	}
    }
    You have to parse each element individually.

    Code:
    Private Sub Form_Load()
        
        Dim jsonFile As String, line() As String, i As Long, errs As Long
        
        sc.UseSafeSubset = True
        sc.Language = "JScript"
        
        jsonFile = ReadFile(app.path & "\test_json.txt")
        line = Split(jsonFile, vbCrLf)
        
        For i = 0 To UBound(line)
            If Len(line(i)) > 0 Then
                If Not LoadJson(line(i)) Then
                    Debug.Print "Error on element: " & i & " Error Line:" & sc.Error.line & ": " & sc.Error.Description
                    errs = errs + 1
                Else
                    Debug.Print i & ") " & sc.Eval("json.properties.city")
                End If
            End If
        Next
        
        Debug.Print "Errors: " & errs
        
    End Sub
    
    Function LoadJson(ByVal JSON As String) As Boolean
        
        On Error Resume Next
        sc.Reset
        JSON = "var None=''; var True=1; var False=0; var json = " & JSON
        sc.AddCode JSON
        LoadJson = (Err.Number = 0)
        
    End Function
     
    Function ReadFile(filename)
      Dim f, temp
      f = FreeFile
      temp = ""
       Open filename For Binary As #f        ' Open file.(can be text or image)
         temp = Input(FileLen(filename), #f) ' Get entire Files data
       Close #f
       ReadFile = temp
    End Function
    SORRY...

    but on this line:

    sc.UseSafeSubset = True

    have error in sc., variable not dfined!

  22. #22
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,056

    Re: JSON node retrive info

    the sc object was an instance of the Microsoft Script Control.

    You can either Add Component MSScriptControl then put an instance on your form named sc

    or the following will work too

    Code:
    Dim sc As Object
    
    Private Sub Form_Load()
        
        Dim jsonFile As String, line() As String, i As Long, errs As Long
        
        Set sc = CreateObject("MSScriptControl.ScriptControl")

  23. #23
    Hyperactive Member
    Join Date
    Nov 2011
    Posts
    498

    Re: JSON node retrive info

    Quote Originally Posted by dz32 View Post
    the sc object was an instance of the Microsoft Script Control.

    You can either Add Component MSScriptControl then put an instance on your form named sc

    or the following will work too

    Code:
    Dim sc As Object
    
    Private Sub Form_Load()
        
        Dim jsonFile As String, line() As String, i As Long, errs As Long
        
        Set sc = CreateObject("MSScriptControl.ScriptControl")
    try test 2 https://www.dropbox.com/s/cg0wi0oyb5...test2.zip?dl=0

  24. #24

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: JSON node retrive info

    Quote Originally Posted by dz32 View Post
    the sc object was an instance of the Microsoft Script Control.

    You can either Add Component MSScriptControl then put an instance on your form named sc

    or the following will work too

    Code:
    Dim sc As Object
    
    Private Sub Form_Load()
        
        Dim jsonFile As String, line() As String, i As Long, errs As Long
        
        Set sc = CreateObject("MSScriptControl.ScriptControl")
    wow!!!!

    Work, perferct.

    but i have a null value in the last node:

    Debug.Print i & ") " & UCase(SC.Eval("json.properties.coordinates"))

  25. #25
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,056

    Re: JSON node retrive info

    there is no json.properties.coordinates

    Code:
    {
    	"type": "Feature",
    	"properties": {
    		"hash": "0471ff336a327263",
    		"number": "23",
    		"street": "Via 4 Aprile",
    		"unit": "",
    		"city": "ARAGONA",
    		"district": "AGRIGENTO",
    		"region": "SICILIA",
    		"postcode": "92021",
    		"id": "13800023883257"
    	},
    	"geometry": {
    		"type": "Point",
    		"coordinates": [13.616626, 37.405944]
    	}
    }
    
    try any of these
        json.geometry.coordinates
        json.geometry.coordinates[0]
        json.geometry.coordinates[1]
        json.geometry.coordinates.join('\t')

  26. #26

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: JSON node retrive info

    Quote Originally Posted by dz32 View Post
    there is no json.properties.coordinates

    Code:
    {
    	"type": "Feature",
    	"properties": {
    		"hash": "0471ff336a327263",
    		"number": "23",
    		"street": "Via 4 Aprile",
    		"unit": "",
    		"city": "ARAGONA",
    		"district": "AGRIGENTO",
    		"region": "SICILIA",
    		"postcode": "92021",
    		"id": "13800023883257"
    	},
    	"geometry": {
    		"type": "Point",
    		"coordinates": [13.616626, 37.405944]
    	}
    }
    
    try any of these
        json.geometry.coordinates
        json.geometry.coordinates[0]
        json.geometry.coordinates[1]
        json.geometry.coordinates.join('\t')
    sorry, but i cannot set the last modify of code, based coordinates.
    can you post the correct code?
    tks.

    my last code:
    Code:
    Private Sub Form_Load()
        
        Dim jsonFile As String, line() As String, i As Long, errs As Long
        
         Set SC = CreateObject("MSScriptControl.ScriptControl")
        
        SC.UseSafeSubset = True
        SC.Language = "JScript"
        
        jsonFile = ReadFile("C:\TABULATI\test_json.txt")
        line = Split(jsonFile, vbCrLf)
        
        For i = 0 To UBound(line)
            If Len(line(i)) > 0 Then
                If Not LoadJson(line(i)) Then
                    Debug.Print "Error on element: " & i & " Error Line:" & SC.Error.line & ": " & SC.Error.Description
                    errs = errs + 1
                Else
                    Debug.Print i & ") " & SC.Eval("json.properties.city")
                    Debug.Print i & ") " & SC.Eval("json.properties.number")
                    Debug.Print i & ") " & UCase(SC.Eval("json.properties.street"))
                    Debug.Print i & ") " & UCase(SC.Eval("json.properties.city"))
                    Debug.Print i & ") " & UCase(SC.Eval("json.properties.district"))
                    Debug.Print i & ") " & UCase(SC.Eval("json.properties.region"))
                    Debug.Print i & ") " & UCase(SC.Eval("json.properties.postcode"))
                    Debug.Print i & ") " & UCase(SC.Eval("json.properties.id"))
                    
                    JSON.geometry.coordinates
        Debug.Print i & ") " & JSON.geometry.coordinates; [0]
        Debug.Print i & ") " & JSON.geometry.coordinates; [1]
        Debug.Print i & ") " & json.geometry.coordinates.join("\t')
                    
                    'Debug.Print i & ") " & UCase(SC.Eval("json.properties.coordinates"))
                    
                End If
            End If
        Next
        
        Debug.Print "Errors: " & errs
        
    End Sub
    Last edited by luca90; May 29th, 2023 at 11:44 AM.

  27. #27
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,056

    Re: JSON node retrive info

    Humm something looks different between the lines that work and those that don’t. Can’t quite put my finger on it though? 🤷
    Last edited by dz32; May 29th, 2023 at 12:19 PM.

  28. #28

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: JSON node retrive info

    Quote Originally Posted by dz32 View Post
    Humm something looks different between the lines that work and those that don’t. Can’t quite put my finger on it though? 🤷
    TKS bro.

    read with attention your last post based coordinates, and correct my code.
    Now work like a charm.

    Tks for all and pizza for you, sure.
    I'm Napolitan from Italy.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width