A way to parse this rather strange api

before a mod attempts to fold this into an older topic, hear me out. im just having one heck of a time trying to get this, while incredibly informative, json to post in an eyeball friendly manner.

in a list, I’ve gotten it to display a single letter in each list item, display the number of letters in the entire thing, and now its just crashing the app over and over again.

this is what i was able to get by slamming the wall of dmv text into a json formatter, it looks as if its one array with 140 some-odd items crammed into it. I’ve been trying this for almost 6 hours now and I’m starting to het to the point where I’m yelling at my laptop, lol.

the docs dont seem to have an answer for how to cut this one… and following any of the other tutorials on the forums has just lead to crashing

any suggestions would be greatly appreciated and incredibly welcome!

here’s the dmv website, i got the api to work properly, but this is giving me trouble…
Vehicle API

the confoundingly different api response:

{
“Count”: 142,
“Message”: “Results returned successfully. NOTE: Any missing decoded values should be interpreted as NHTSA does not have data on the specific variable. Missing value should NOT be interpreted as an indication that a feature or technology is unavailable for a vehicle.”,
“SearchCriteria”: “VIN(s): 5UXWX7C5BA",
“Results”: [
{
“ABS”: “”,
“ActiveSafetySysNote”: “”,
“AdaptiveCruiseControl”: “”,
“AdaptiveDrivingBeam”: “”,
“AdaptiveHeadlights”: “”,
“AdditionalErrorText”: “”,
“AirBagLocCurtain”: “”,
“AirBagLocFront”: “1st Row (Driver & Passenger)”,
“AirBagLocKnee”: “”,
“AirBagLocSeatCushion”: “”,
“AirBagLocSide”: “1st Row (Driver & Passenger)”,
“AutoReverseSystem”: “”,
“AutomaticPedestrianAlertingSound”: “”,
“AxleConfiguration”: “”,
“Axles”: “”,
“BasePrice”: “”,
“BatteryA”: “”,
“BatteryA_to”: “”,
“BatteryCells”: “”,
“BatteryInfo”: “”,
“BatteryKWh”: “”,
“BatteryKWh_to”: “”,
“BatteryModules”: “”,
“BatteryPacks”: “”,
“BatteryType”: “”,
“BatteryV”: “”,
“BatteryV_to”: “”,
“BedLengthIN”: “”,
“BedType”: “”,
“BlindSpotMon”: “”,
“BodyCabType”: “”,
“BodyClass”: “Sport Utility Vehicle (SUV)/Multi-Purpose Vehicle (MPV)”,
“BrakeSystemDesc”: “”,
“BrakeSystemType”: “”,
“BusFloorConfigType”: “Not Applicable”,
“BusLength”: “”,
“BusType”: “Not Applicable”,
“CAN_AACN”: “”,
“CIB”: “”,
“CashForClunkers”: “”,
“ChargerLevel”: “”,
“ChargerPowerKW”: “”,
“CoolingType”: “”,
“CurbWeightLB”: “”,
“CustomMotorcycleType”: “Not Applicable”,
“DaytimeRunningLight”: “”,
“DestinationMarket”: “”,
“DisplacementCC”: “2979.1682352”,
“DisplacementCI”: “181.8”,
“DisplacementL”: “3.0”,
“Doors”: “4”,
“DriveType”: “”,
“DriverAssist”: “”,
“DynamicBrakeSupport”: “”,
“EDR”: “”,
“ESC”: “”,
“EVDriveUnit”: “”,
“ElectrificationLevel”: “”,
“EngineConfiguration”: “”,
“EngineCycles”: “”,
“EngineCylinders”: “6”,
“EngineHP”: “300”,
“EngineHP_to”: “”,
“EngineKW”: “223.7100”,
“EngineManufacturer”: “”,
“EngineModel”: “”,
“EntertainmentSystem”: “”,
“ErrorCode”: “6”,
“ErrorText”: “6 - Incomplete VIN”,
“ForwardCollisionWarning”: “”,
“FuelInjectionType”: “”,
“FuelTypePrimary”: “Gasoline”,
“FuelTypeSecondary”: “”,
“GCWR”: “”,
“GCWR_to”: “”,
“GVWR”: “Class 1D: 5,001 - 6,000 lb (2,268 - 2,722 kg)”,
“GVWR_to”: “”,
“KeylessIgnition”: “”,
“LaneDepartureWarning”: “”,
“LaneKeepSystem”: “”,
“LowerBeamHeadlampLightSource”: “”,
“Make”: “BMW”,
“MakeID”: “452”,
“Manufacturer”: “BMW MANUFACTURER CORPORATION / BMW NORTH AMERICA”,
“ManufacturerId”: “968”,
“Model”: “X3”,
“ModelID”: “1719”,
“ModelYear”: “2011”,
“MotorcycleChassisType”: “Not Applicable”,
“MotorcycleSuspensionType”: “Not Applicable”,
“NCSABodyType”: “Compact Utility (Utility Vehicle Categories "Small" and "Midsize")”,
“NCSAMake”: “BMW”,
“NCSAMapExcApprovedBy”: “”,
“NCSAMapExcApprovedOn”: “”,
“NCSAMappingException”: “”,
“NCSAModel”: “X3”,
“NCSANote”: “”,
“Note”: “”,
“OtherBusInfo”: “”,
“OtherEngineInfo”: “”,
“OtherMotorcycleInfo”: “”,
“OtherRestraintSystemInfo”: “Head Inflatable Restraint for Driver, Front Passenger, Rear Outboard Driver-side and Rear Outboard Passenger-side. Knee Inflatable Restraint for Driver. Pretensioners for Driver and Front Passenger.”,
“OtherTrailerInfo”: “”,
“ParkAssist”: “”,
“PedestrianAutomaticEmergencyBraking”: “”,
“PlantCity”: “MUNICH”,
“PlantCompanyName”: “”,
“PlantCountry”: “GERMANY”,
“PlantState”: “”,
“PossibleValues”: “”,
“Pretensioner”: “Yes”,
“RearCrossTrafficAlert”: “”,
“RearVisibilitySystem”: “”,
“SAEAutomationLevel”: “”,
“SAEAutomationLevel_to”: “”,
“SeatBeltsAll”: “Manual”,
“SeatRows”: “”,
“Seats”: “”,
“SemiautomaticHeadlampBeamSwitching”: “”,
“Series”: “X3”,
“Series2”: “”,
“SteeringLocation”: “”,
“SuggestedVIN”: “”,
“TPMS”: “Direct”,
“TopSpeedMPH”: “”,
“TrackWidth”: “”,
“TractionControl”: “”,
“TrailerBodyType”: “Not Applicable”,
“TrailerLength”: “”,
“TrailerType”: “Not Applicable”,
“TransmissionSpeeds”: “”,
“TransmissionStyle”: “”,
“Trim”: “xDrive35i”,
“Trim2”: “SAV”,
“Turbo”: “”,
“VIN”: "5UXWX7C5
BA”,
“ValveTrainDesign”: “”,
“VehicleType”: “MULTIPURPOSE PASSENGER VEHICLE (MPV)”,
“WheelBaseLong”: “”,
“WheelBaseShort”: “”,
“WheelBaseType”: “”,
“WheelSizeFront”: “”,
“WheelSizeRear”: “”,
“Wheels”: “”,
“Windows”: “”
}
]
}

Here is a link to my approach

Go one level at a time checking the available properties. The is is a list of objects, which can make it a bit tricky. Try to isolate you parsing routine and post both the blocks and the results to the group and we can provide more specific feedback.

Basically, all I’m trying to do is make an app that you type the vin number of a car in, and get a list of those provided data types, if available.

I’m not sure what part is causing the object blocks so much trouble

Thanks for the suggestion, I’ve gone through so many of the other threads before posting, so that I was absolutely sure that my problem was relatively unique enough to warrant a new thread.

All I’m trying to do is either get a bulleted list of raw text or cram it into a list viewer

This screenshot is all I’ve managed using a random vin number for a mini cooper.

Not exactly user friendly lol… I might have to talk to a staff member or something, because clearly I’m missing something obvious that I’m just not aware of

The properties method just returned the number of characters in the response… So weird… It said there were over 1000 properties, lol, definitely not 1000 there

This is the next thing I’m going to try out, take the stuff from the json, slam it I to a local db, and work from there… Probably not going to work, but I don’t give up, lol.

Are you saying that the same API call using different VIN #s results in uniquely-formatted JSON responses? Or are you just having trouble parsing a single type of JSON response? If it’s the latter, what property, as an example, are you trying to access?

Here’s a demo that will give you the Make & Model:

https://x.thunkable.com/projects/5ff600020db77cca2e9226de/ae8554e4-667f-4fc2-a628-fa33d7331475/designer

3 Likes

sorry for the delayed response, i was passed out, i finally gave up at midnight, in my time at least, but this is about as good as i could get it, the blocks are a mess, lol.

i was planning on using the method shown below, and setting up a “for every item in list j” loop that increased a variable ,that variable would save everything before and after the semicolon as “1a, 1b, 2a, 2b,” and so on. the idea was to get retrievable info for later. the local database wouldn’t work this way so i was going to do this using local storage… yea, what i ack in intellect i make up for with an inhuman amount of diligence, lol.

My Sorta-Successful(but not really) attempt

ill try and see if i can reverse engineer what you’ve done there later today, here’s to hope, friend!

My apologies @bluefox2277k0zb, I misunderstood what you were trying to do.

Thunkable has a built in JSON parser

You can read more about Thunkable Objects here https://docs.thunkable.com/objects

1 Like

yeah, that just crashed when i tried before… but i dont remember if i did that exact thing… :sweat_smile:

If the Response is not correctly formatted JSON, it will blow up. That can often occur if there is an error in the Web API call or if the status is an unsuccessful code (400s).

I will usually add if blocks to check both of those conditions first, but I wanted to highlight the Get Object block.

What I had done was, instead of a variable, used a label, and I think one time I tried using a list viewer, and then, I can’t remember what did what because I tried so many times, but one time it just made a list viewer with one letter per list viewer item.

And the other time it just made a list viewer that just counted the number of characters in the response, I’m guessing on this one, because it was over 1000 list viewer items, lol

Right, there are all sorts of issues that will occur when setting component properties (text, list, etc) to values the component can’t handle. Since Thunkable doesn’t really trap errors, the only way to keep your app stable is to verify the JSON property is of the kind you are expecting.

Tedious, but I haven’t found another solution.

Best of luck!

Curious if my demo was helpful for you? It includes error handling and JSON parsing.

2 Likes

it was! genuinely, mi just on to the next step, which is making them into a list, which involves making substrings and subsists.

thank you, genuinely, that basically made my entire project jump forward by quite a bit.

I’m actually going to make a demo and post it in a bit!!

3 Likes

I’m going to use your method to do much more useful things, but this is just a data dump, LMK what you think!
I’ve been getting vin numbers to test from here: https://vingenerator.org/

aaand here’s the link to the datadump-list app: https://thunkable.site/w/c9WLavecy

the demo tatiang posted was perfect, quite by accident, i figured out this method for just getting the raw info from a large list of objects and their parameters. although, i think, it only works in this 1:1 ratio situation where the list had them listed as one value per-parameter. sorry if the terminology is off :sweat_smile: im a mechanic, not a programmer, lol.

blocks:

1 Like

Looks complicated but then JSON always is! If you need more help, let us know. I’m honestly not following everything you’re doing but I can always dig a bit. It helps if you can either show a sketch of what you want (e.g. the values you’re expecting to see in a listviewer) or give a description such as “I want to display a list of the Make from 100 different VINs” or “I want to list the first 30 values for a single VIN, such as ABS, ActiveSafetySysNote, AdaptiveCruiseControl, etc.”

1 Like

I’m just trying to get a handle on json… its something that I’ve put off for a while now…

the next step is firebase stuff, wish me luck.
i literally have half a mind to just use Airtable for the user data stuff, lmao

1 Like

Well, JSON was a journey for me and now I feel pretty comfortable with it. Firebase was very recent – last couple weeks – and it’s really powerful and not too difficult. I was a fan of Airtable but it has too many issues with Thunkable and Firebase is just way more flexible and quick.

The nice thing about Firebase is that YOU decide the data structure rather than with JSON where you have to decipher all this gobblygook just to find what you’re looking for. And Firebase ends up looking like a bulleted list/outline, which we’re all familiar with from school/business.

2 Likes

but, from what i understand, i create structures that function like multi layered lists in Microsoft word, and that becomes the structure of the json?
in fire base , for example

its like

  1. group name
    A. Variable: value
    B. Variable: value
    C. Variable: value
  2. group name
    A. Variable: value
    B. Variable: value
    C. Variable: value
  3. group name
    A. Variable: value
    B. Variable: value
    C. Variable: value
    and i have to structure the blocks, seemingly backwards, to get this stuff from the firebase json using the firebase realtimeDB
1 Like