Aerospike.Database.LINQPadDriver.Extensions Namespace
Aerospike LINDPad Driver

ANamespaceAccess..::..FromJson Method (String, String, String, String, WritePolicy, Nullable<(Of <(<'TimeSpan>)>)>, Boolean, IList<(Of <(<'ARecord>)>)>, Boolean)

Converts a Json string into an ARecord which is than put into setName. Each top-level property in the Json is translated into a bin and value. Json Arrays and embedded objects are transformed into an Aerospike List or Map<string,object>. Note: If the Json string is an Json Array, each element is treated as a separate record. If the Json string is a Json Object, the following behavior occurs: If jsonBinName is provided, the Json object is treated as an Aerospike document which will be associated with that bin. if jsonBinName is null, each json property in that Json object is treated as a separate bin/value. You can also insert individual records by calling FromJson(String, String, String, String, WritePolicy, Nullable<(Of <<'(TimeSpan>)>>), Boolean, IList<(Of <<'(ARecord>)>>), Boolean).

Namespace:  Aerospike.Database.LINQPadDriver.Extensions
Assembly:  Aerospike.Database.LINQPadDriver (in Aerospike.Database.LINQPadDriver.dll)

Syntax


public int FromJson(
	string setName,
	string json,
	string pkPropertyName,
	string jsonBinName,
	WritePolicy writePolicy,
	Nullable<TimeSpan> ttl,
	bool writePKPropertyName,
	IList<ARecord> insertIntoList,
	bool treatEmptyStrAsNull
)

Parameters

setName
Type: String
Set name or null for the null set. This can be a new set that will be created.
json
Type: String
The Json string. note: in-line json types are supported. Example:
C#
"bucket_start_date": "$date": { "$numberLong": "1545886800000"}}
pkPropertyName
Type: String
The property name used for the primary key. The default is '_id'. If the primary key value is not present, the digest is used. In these cases the property value will be a sub property where that name will be '$oid' and the value is a byte string.
jsonBinName
Type: String
If provided, the Json object is placed into this bin. If null (default), the each top level Json property will be associated with a bin. Note, if the property name is greater than the bin name limit, an Aerospike exception will occur during the put.
writePolicy
Type: WritePolicy
The write policy. If not provided , the default policy is used.
ttl
Type: Nullable<(Of <(<'TimeSpan>)>)>
Time-to-live of the record
writePKPropertyName
Type: Boolean
If true, the pkPropertyName, is written to the record. If false (default), it will not be written to the set (only used to define the PK).
insertIntoList
Type: IList<(Of <(<'ARecord>)>)>
If provided, records are inserted into this collection instead of inserting into the database.
treatEmptyStrAsNull
Type: Boolean
If true, default, these properties with an empty string value will be considered null (bin not saved). If false, these properties with an empty string value will have a bin value of empty string.

Return Value

The number of items put.

Exceptions


ExceptionCondition
KeyNotFoundException Thrown if the pkPropertyName is not found as a top-level field.
InvalidDataException Thrown if an unexpected data type is encountered.

Remarks


The Json string can include Json in-line types. Below are the supported types:
C#
$date
or
C#
$datetime
, This can include an optional sub Json Type.Example:
C#
"bucket_start_date": "$date": { "$numberLong": "1545886800000"}}
C#
$datetimeoffset
, This can include an optional sub Json Type. Example:
C#
"bucket_start_datetimeoffset": "$datetimeoffset": { "$numberLong": "1545886800000"}}
C#
$timespan
, This can include an optional sub Json Type. Example:
C#
"bucket_start_time": "$timespan": { "$numberLong": "1545886800000"}}
C#
$timestamp
,
C#
$guid
or
C#
$uuid
,
C#
$oid
, If the Json string value equals 40 in length it will be treated as a digest and converted into a byte array. Example:
C#
"_id": { "$oid ": "0080a245fabe57999707dc41ced60edc4ac7ac40" }
==>
C#
"_id":[00 80 A2 45 FA BE 57 99 97 07 DC 41 CE D6 0E DC 4A C7 AC 40]
C#
$numberint64
or
C#
$numberlong
,
C#
$numberint32
, or
C#
$numberint
,
C#
$numberdecimal
,
C#
$numberdouble
,
C#
$numberfloat
or
C#
$single
,
C#
$numberint16
or
C#
$numbershort
,
C#
$numberuint32
or
C#
$numberuint
,
C#
$numberuint64
or
C#
$numberulong
,
C#
$numberuint16
or
C#
$numberushort
,
C#
$bool
or
C#
$boolean
;