Source/NFX/Serialization/JSON/JSONReader.cs
/// <summary>
/// Converts JSONMap into typed row of the requested type.
/// The requested type must be derived from NFX.DataAccess.CRUD.TypedRow.
/// The extra data found in JSON map will be placed in AmorphousData dictionary if the row implemets IAmorphousData, discarded otherwise.
/// Note: This method provides "the best match" and does not guarantee that all data will/can be converted from JSON, i.e.
///  it can only convert one dimensional arrays and Lists of either primitive or TypeRow-derived entries
/// </summary>
/// <param name="type">TypedRow subtype to convert into</param>
/// <param name="jsonMap">JSON data to convert into row</param>
/// <param name="fromUI">When true indicates that data came from UI, hence NonUI-marked fields should be skipped. True by default</param>
/// <param name="nameBinding">Used for backend name matching or null (any target)</param>
Converts JSONMap into typed row of the requested type.
The requested type must be derived from NFX.DataAccess.CRUD.TypedRow.
The extra data found in JSON map will be placed in AmorphousData dictionary if the row implemets IAmorphousData, discarded otherwise.
Note: This method provides "the best match" and does not guarantee that all data will/can be converted from JSON, i.e.
it can only convert one dimensional arrays and Lists of either primitive or TypeRow-derived entries
Converts JSONMap into typed row of the requested type . The requested type must be derived from NFX . DataAccess . CRUD . TypedRow . The extra data found in JSON map will be placed in AmorphousData dictionary if the row implemets IAmorphousData discarded otherwise . Note : This method provides " the best match " and does not guarantee that all data will / can be converted from JSON i . e . it can only convert one dimensional arrays and Lists of either primitive or TypeRow - derived entries
public static TypedRow ToRow(Type type, JSONDataMap jsonMap, bool fromUI = true, NameBinding? nameBinding = null)
            {
              if (!typeof(TypedRow).IsAssignableFrom(type) || jsonMap==null)
               throw new JSONDeserializationException(StringConsts.ARGUMENT_ERROR+"JSONReader.ToRow(type|jsonMap=null)");
              var field = "";
              try
              {
                return toTypedRow(type, nameBinding, jsonMap, ref field, fromUI);
              }
              catch(Exception error)
              {
                throw new JSONDeserializationException("JSONReader.ToRow(jsonMap) error in '{0}': {1}".Args(field, error.ToMessageWithType()), error);
              }
            }
public static TypedRow ToRow ( Type type , JSONDataMap jsonMap , bool fromUI = true , NameBinding ? nameBinding = null ) { if ( ! typeof ( TypedRow ) . IsAssignableFrom ( type ) || jsonMap == null ) throw new JSONDeserializationException ( StringConsts . ARGUMENT_ERROR + " " ) ; var field = " " ; try { return toTypedRow ( type , nameBinding , jsonMap , ref field , fromUI ) ; } catch ( Exception error ) { throw new JSONDeserializationException ( " " . Args ( field , error . ToMessageWithType ( ) ) , error ) ; } }
Converts JSONMap into typed row of the requested type.
Converts JSONMap into typed row of the requested type .
type
Type
TypedRow subtype to convert into
TypedRow subtype to convert into
jsonMap
JSONDataMap
JSON data to convert into row
JSON data to convert into row
fromUI
bool
When true indicates that data came from UI, hence NonUI-marked fields should be skipped. True by default
When true indicates that data came from UI hence NonUI - marked fields should be skipped . True by default
nameBinding
NameBinding?
Used for backend name matching or null (any target)
Used for backend name matching or null ( any target )