HISE Logo Forum
    • Categories
    • Register
    • Login

    Unknown property name in JSON

    Scheduled Pinned Locked Moved General Questions
    json
    4 Posts 3 Posters 357 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ustkU
      ustk
      last edited by ustk

      I'm back on track with my old friend JSON issue

      Is there a way to get the file property without knowing the "unknown" property name?

      {
        "meta": {
          "unknown1": {
            "file": "value1"
          },
          "unknown2": {
            "file": "value2"
          }
        }
      }
      

      I know there are methods in javascript but it's not the same story with Hise...

      I can place the names in an array like so ["unknown1", "unknown2"],
      but then meta.array[i] obviously won't work more than any iteration method like meta[i] or u in meta

      @d-healey, I know you made a parser a while ago that is able to find a different number of elements in an object.
      Could it be a worthy solution to explore?

      Can't help pressing F5 in the forum...

      ulrikU d.healeyD 2 Replies Last reply Reply Quote 0
      • ulrikU
        ulrik @ustk
        last edited by

        @ustk
        Do you mean like this?

        for (i in json.meta)
        {
        	var p = json.meta[i];
        	
        	for (j in p)
        		var v = p[j];
        
        	Console.print(v);
        }
        

        Hise Develop branch
        MacOs 15.3.1, Xcode 16.2
        http://musikboden.se

        ustkU 1 Reply Last reply Reply Quote 1
        • d.healeyD
          d.healey @ustk
          last edited by

          @ustk said in Unknown property name in JSON:

          @d-healey, I know you made a parser a while ago that is able to find a different number of elements in an object.

          I added String.parseAsJSON(), is that what you're referring to? I don't think that will be any use here. I'd do what @ulrik suggested.

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

          1 Reply Last reply Reply Quote 1
          • ustkU
            ustk @ulrik
            last edited by

            @ulrik Thanks a lot! It is so strange because I tried a very similar method for accessing the properties using [] with no luck. For some reason I was always returning the name of the key rather han the object itself...
            You saved me :)

            @d-healey I say parser but I reckon it was an object sorter of some kind... @ulrik solution is indeed what I need

            Thanks guys!

            Can't help pressing F5 in the forum...

            1 Reply Last reply Reply Quote 1
            • First post
              Last post

            17

            Online

            1.7k

            Users

            11.9k

            Topics

            103.5k

            Posts