The the specific question you are asking ("is possible to access struct fields dynamically in generated code"), the answer is "no". Where is why:
MATLAB Coder aims to translate MATLAB into statically typed C/C++ code, similar to what a human would write. To that extent, it translates MATLAB structures into C/C++ structs. In C and C++, the list of fields in a struct, each use of a field must be statically resolved.
So, whenever codegen sees "var.(field)", it wants to find out the value of the variable "field" at compile time. If it could not do so, it produces an error. Also, it wants to know, at compile time, what is the full list of fields in a struct.
If you elaborate on your intent (what you want to achieve, why you'd want to generate C/C++ code using MATLAB Coder and parse Json there) someone could suggest an alternative solution.
For instance, if you know the full list of fields ahead of time, and all the fields have same types, you could write something akin to
function out = dynFieldAccess(var, fieldname)
if strcmp(fieldname, 'a')
out = var.a;
else if strcmp(fieldname, 'b')
out = var.b;
and so on.
Or maybe you'd be better off hand-writing the C/C++ code for this part of your application.