nogepog
4 months ago

how to access json values to check conditionals

Posted 4 months ago by nogepog

I have converted a model to JSON which returns the following

[{"car_id":1,"pieces":"6"}, {"car_id":2,"pieces":"1"}, {"car_id":3,"pieces":"7"}, {"car_id":4,"pieces":"3"}, {"car_id":5,"pieces":"3"}]

how do i access the carid and pieces as seperate variables to run multiple if criteria

e.g if car_id 4 has pieces less than 3 print "this" ,equal to 3 print "this"

Please sign in or create an account to participate in this conversation.