Forum

    • Register
    • Login
    • Search
    • Categories

    Unknown property name in JSON

    General Questions
    json
    3
    4
    48
    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.
    • ustk
      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?

      Tired to press F5 in the forum...
      Studio427 Audio - Audio Instruments & FX Plugins for music production. Website - Facebook

      ulrik d.healey 2 Replies Last reply Reply Quote 0
      • ulrik
        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 12.4, Xcode 13.0
        http://musikboden.se

        ustk 1 Reply Last reply Reply Quote 1
        • d.healey
          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
          • ustk
            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!

            Tired to press F5 in the forum...
            Studio427 Audio - Audio Instruments & FX Plugins for music production. Website - Facebook

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

            20
            Online

            742
            Users

            5.4k
            Topics

            50.4k
            Posts