public class Prog
{
public int min { get; set; }
public int val { get; set; }
public int max { get; set; }
}
When i convert the class above at runtime, a $p_ is added to each property at runetime.
but if i define the class like this:
public class Prog
{
public int min;
public int val;
public int max;
}
Properties have an underlying variable that start with $p_ so they don’t interfere with other members in the class (Everything must be unique), the only time you ever get to see those is in the debugger, which currently does not hide that detail for you.
Here is a string extension that sets the field values rather than returning zero for .net property definition syntax.
public static E JSONSrtringToType<E>(this string f, Class<E> cls){
var type = cls.newInstance();
JSONObject jo = new JSONObject(f);
foreach(var t in type.Class.DeclaredFields)
{
Field field = type.Class.getDeclaredField(t.Name);
field.Accessible = true;
object value = t.Name.contains("$p_") ? jo.get(t.Name.replace("$p_","")) : jo.get(t.Name);
field.set(type,value);
}
return type;
}