<commit_before>library Json;

import 'dart:convert';
import 'dart:mirrors';
import 'Serializable.dart';



class Json<T extends Serializable>
{  
 
  T FromJson(String json)
  {
    if (json == null) {
      return null;
    }
    
    ClassMirror cm = reflect(this).type;
    ClassMirror cm2 = cm.typeArguments[0] as ClassMirror;
    
    InstanceMirror instanceMirror = cm2.newInstance(const Symbol(""), []);
    T newInstance =  instanceMirror.reflectee;
    
    Map pollMap = JSON.decode(json);
    pollMap.forEach((String K, Object V) {
      Symbol symbol = new Symbol(K);
      DeclarationMirror dm = cm2.declarations[symbol];
      instanceMirror.setField(symbol, V);
    });
    
    return newInstance;
  }
  
}
<commit_msg>deserialize json<commit_after>library Json;

import 'dart:convert';
import 'dart:mirrors';
import 'Serializable.dart';



class Json<T extends Serializable>
{  
 
  T FromJson(String json)
  {
    if (json == null) {
      return null;
    }
    
    ClassMirror cm = reflect(this).type;
    ClassMirror cm2 = cm.typeArguments[0] as ClassMirror;
    
    InstanceMirror instanceMirror = cm2.newInstance(const Symbol(""), []);
    T newInstance =  instanceMirror.reflectee;
    
    Map pollMap = JSON.decode(json);
    pollMap.forEach((String K, Object V) {
      Symbol symbol = new Symbol(K);
      VariableMirror vm = cm2.declarations[symbol];
      TypeMirror tm = vm.type;
      if (tm.simpleName == const Symbol("DateTime")) {
        var dt = DateTime.parse(V);
        instanceMirror.setField(symbol, dt);
      } else {
        instanceMirror.setField(symbol, V);
      }
    });
    
    return newInstance;
  }
  
}

{'fraction_non_alphanumeric': 0.11290322580645161, 'fraction_numerical': 0.004608294930875576, 'mean_word_length': 2.4464285714285716, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3690360', 'n_tokens_mistral': 567, 'n_tokens_neox': 532, 'n_words': 120}