Hi all,

I manage a pcars2 league in a simracing community and we have a hotlap tracking app which imports valid laptimes from sms_stats_data.json to an sql database for later use. The problem is the huge amount of inconsistencies I have to deal with inside the sms_stats_data.json file...

All this examples are taken from the same 1 week long sms_stats_data.json with only practice sessions allowed.

Inconsistencies in PARTICIPANTS subarrays:

Sometimes the subarray is keyed with the "participantid" field, sometimes not...

Case 1 example:
Code:
"participants" : {
  "0" : {
	"IsPlayer" : 1,
	"LiveryId" : 73,
	"Name" : "Hidden on purpose",
	"RefId" : 63872,
	"VehicleId" : 1353949246
  }
},
Case 2 example:
Code:
"participants" : [
  {
	"IsPlayer" : 1,
	"LiveryId" : 53,
	"Name" : "Hidden on purpose",
	"RefId" : 50688,
	"VehicleId" : 1153746660
  }
],
This issue happens with one or with more than one participants.

In this next case, you can see another problem, that is the player name being empty:

Code:
"participants" : {
  "0" : {
	"IsPlayer" : 1,
	"LiveryId" : 54,
	"Name" : "Hidden on purpose",
	"RefId" : 22080,
	"VehicleId" : 809291220
  },
  "1" : {
	"IsPlayer" : 1,
	"LiveryId" : 99,
	"Name" : "",
	"RefId" : 49153,
	"VehicleId" : -1416203489
  },
  "2" : {
	"IsPlayer" : 1,
	"LiveryId" : 99,
	"Name" : "Hidden on purpose",
	"RefId" : 9793,
	"VehicleId" : -1416203489
  },
  "3" : {
	"IsPlayer" : 1,
	"LiveryId" : 69,
	"Name" : "Hidden on purpose",
	"RefId" : 44418,
	"VehicleId" : -1860886593
  },
  "4" : {
	"IsPlayer" : 1,
	"LiveryId" : 99,
	"Name" : "Hidden on purpose",
	"RefId" : 2369,
	"VehicleId" : -93033971
  },
  "5" : {
	"IsPlayer" : 1,
	"LiveryId" : 99,
	"Name" : "",
	"RefId" : 53314,
	"VehicleId" : 1153746660
  },
  "6" : {
	"IsPlayer" : 1,
	"LiveryId" : 78,
	"Name" : "Hidden on purpose",
	"RefId" : 30529,
	"VehicleId" : -1860886593
  },
  "7" : {
	"IsPlayer" : 1,
	"LiveryId" : 59,
	"Name" : "Hidden on purpose",
	"RefId" : 24642,
	"VehicleId" : 809291220
  },
  "8" : {
	"IsPlayer" : 1,
	"LiveryId" : 99,
	"Name" : "Hidden on purpose",
	"RefId" : 36995,
	"VehicleId" : -93033971
  }
},
When this happens, the only solution I found is to get the participantid from the laptime event and search in the corresponding session's participants array, but that is not possible when there is no key in the latter, as I mentioned earlier. You can see this on the following case, which corresponds to a laptime registered in the same session as Case 2 example:

Code:
{
"attributes" : {
  "IsMainBranch" : 1,
  "Lap" : 0,
  "LapTime" : 20417,
  "RacePosition" : 1
},
"event_name" : "CutTrackStart",
"is_player" : true,
"name" : "Hidden on purpose",
"participantid" : 1,
"refid" : 50688,
"time" : 1604411036
},
I solved this with a refid value check for each participant, but this overcomplicates the code innecessarily.

Inconsistencies in MEMBERS subarrays:

The other major issue is regarding the members subarray, as it is sometimes empty. This would be the source to get the current setup for each player, wether he uses a controller or a wheel or which aids he has activated, and so on. Is would be also the way to get the player's steam ID, but it is sometimes empty and I cannot find the reason.

Conclusion

In the end, I have managed to register every valid lap and store the driver, car, livery, date and time and laptime, with an overcomplicated code full of 'if' statements, but I cannot get the driver configuration nor its steam ID. Has anyone faced this issues before? Has this anything to do with my DS files?