Solved How to read a JSon file by value ?

Discussion in 'Mod Support' started by jojos38, Jul 8, 2017.

  1. jojos38

    jojos38
    Expand Collapse

    Joined:
    Oct 22, 2013
    Messages:
    1,071
    Hi, to fix the last bug of my mod i need to find a way to save 1 value by vehicle and this value contain the vehicle ID.
    And when the user reload the vehicle i want it to search if the JSon file contain this ID.

    I did this:


    Code:
    local latestConfig = readJsonFile("/mods/---/config/latestConfig.json") --Read the JSon file
    
    local vehicleID = **Code to get the vehicle ID**
    
    serializeJsonToFile("mods/---/config/latestConfig.json", vehicleID, true) --Add the vehicleID to the Json file
    
    vehicleConfig = latestConfig.vehicleID
    --But here it say me that i can't. Because he search for a value that is called "vehicheID" in the JSon file, but i want it to search latestConfig.9536    (9536 = vehicleID)
    I don't know if you see what i am trying to do but if someone know how to "call a value by value" (like latestConfig.myValue1 = test)
    It's complicated to explain ^^
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice