API JSON Value Help

{
  "products": {
    "Mercedes Econic Fuel Truck": {
      "name": "Mercedes Econic Fuel Truck",
      "preorder": false,
      "devproduct": 1130599874,
      "users": {
        "1": {
          "status": true,
          "id": "1"
        }
      }
    },
    "Boeing 737 V1": {
      "name": "Boeing 737 V1",
      "preorder": true,
      "devproduct": 1130600202,
      "users": {
        "1": {
          "status": true,
          "id": "1"
        },
        "362190114": {
          "status": true,
          "userid": "362190114"
        }
      }
    }
  }
}

That has been retrieved using an API. How can I get lets say, the first JSON Entries name value?

You can use HttpService:JSONDecode() to decode retrieved JSON data to a table.

How do I get the data though? Just the name value from the first entree.

Same as how you get data from normal tables, in this case it would be:

local ProductTable = {
--Your JSONDecoded Table
}

function getProducts()
    local ReturnTable = {}
    for i, v in pairs(ProductTable) do
        ReturnTable[#ReturnTable + 1] = i
    end
end

And what would that retrieve exactly?

The name of products, like Boeing 737 V1 and Mercedes Econic Fuel Truck by your table above.

and how would I let say get the dev product of the Boeing product?

You use the id that you fetched

what Id did I fetch? huh???

Right here, you said that this is retrieved from an API

And how do I get to the devproduct from here "Mercedes Econic Fuel Truck": {

Simple manipulation will do

local ProductTable = {
--Your JSONDecoded Table
}

function getProducts()
    local ReturnTable = {}
    for i, v in pairs(ProductTable) do
        ReturnTable[i] = {devproduct = ProductTable[i]["devproduct"]}
    end
end
2 Likes

Thanks so much, I really appreicate it