Source/NFX/DataAccess/CRUD/RowsetBase.cs
/// <summary>
/// Reads either Table or Rowset from JSON created by WriteAsJSON. Metadata must be present.
/// allMatched==false when some data did not match schema (i.e. too little fields or extra fields supplied)
/// </summary>
Reads either Table or Rowset from JSON created by WriteAsJSON. Metadata must be present.
allMatched==false when some data did not match schema
Reads either Table or Rowset from JSON created by WriteAsJSON . Metadata must be present . allMatched == false when some data did not match schema
public static RowsetBase FromJSON(JSONDataMap jsonMap,
                                              out bool allMatched,
                                              bool schemaOnly = false,
                                              bool readOnlySchema = false,
                                              SetFieldFunc setFieldFunc = null)
            {
              if (jsonMap == null || jsonMap.Count == 0)
                throw new CRUDException(StringConsts.ARGUMENT_ERROR + "RowsetBase.FromJSON(jsonMap=null)");
              var schMap = jsonMap["Schema"] as JSONDataMap;
              if (schMap==null)
                throw new CRUDException(StringConsts.ARGUMENT_ERROR + "RowsetBase.FromJSON(jsonMap!schema)");
              var schema = Schema.FromJSON(schMap, readOnlySchema);
              var isTable = jsonMap["IsTable"].AsBool();
              allMatched = true;
              var result = isTable ? (RowsetBase)new Table(schema) : (RowsetBase)new Rowset(schema);
              if (schemaOnly) return result;
              var rows = jsonMap["Rows"] as JSONDataArray;
              if (rows==null) return result;
              foreach(var jrow in rows)
              {
                var jdo = jrow as IJSONDataObject;
                if (jdo==null)
                {
                  allMatched = false;
                  continue;
                }
                var row = new DynamicRow(schema);
                if (!Row.TryFillFromJSON(row, jdo, setFieldFunc)) allMatched = false;
                result.Add( row );
              }
              return result;
            }
public static RowsetBase FromJSON ( JSONDataMap jsonMap , out bool allMatched , bool schemaOnly = false , bool readOnlySchema = false , SetFieldFunc setFieldFunc = null ) { if ( jsonMap == null || jsonMap . Count == 0 ) throw new CRUDException ( StringConsts . ARGUMENT_ERROR + " " ) ; var schMap = jsonMap [ " " ] as JSONDataMap ; if ( schMap == null ) throw new CRUDException ( StringConsts . ARGUMENT_ERROR + " " ) ; var schema = Schema . FromJSON ( schMap , readOnlySchema ) ; var isTable = jsonMap [ " " ] . AsBool ( ) ; allMatched = true ; var result = isTable ? ( RowsetBase ) new Table ( schema ) : ( RowsetBase ) new Rowset ( schema ) ; if ( schemaOnly ) return result ; var rows = jsonMap [ " " ] as JSONDataArray ; if ( rows == null ) return result ; foreach ( var jrow in rows ) { var jdo = jrow as IJSONDataObject ; if ( jdo == null ) { allMatched = false ; continue ; } var row = new DynamicRow ( schema ) ; if ( ! Row . TryFillFromJSON ( row , jdo , setFieldFunc ) ) allMatched = false ; result . Add ( row ) ; } return result ; }
Reads either Table or Rowset from JSON created by WriteAsJSON.
Reads either Table or Rowset from JSON created by WriteAsJSON .
jsonMap
JSONDataMap
bool
out
schemaOnly
bool
readOnlySchema
bool
setFieldFunc
SetFieldFunc