SushiHangover.RealmJson.Extensions
Extension Methods for adding JSON APIs to a Realm Instance.
SushiHangover.RealmJson.Extensions Documentation

SushiHangover.RealmJson.Extensions

Extension Methods for adding JSON APIs to a Realm Instance

Current project status:

Nuget:

PM> Install-Package RealmJson.Extensions

Ref: https://www.nuget.org/packages/RealmJson.Extensions

Issues?

Post issues on GitHub

Need Help?

Post on StackOverflow with the tags: **[XAMARIN]** **[REALM]** **[JSON]**

API Reference:

https://sushihangover.github.io/Realm.Json.Extensions/

Extension API:

Usage / Examples:

Single RealmObject from Json-based Strings:

using (var theRealm = Realm.GetInstance(RealmDBTempPath()))
{
    var realmObject = theRealm.CreateObjectFromJson<StateUnique>(jsonString);
}

Single RealmObject from a Stream:

using (var stream = new MemoryStream(byteArray))
using (var theRealm = Realm.GetInstance(RealmDBTempPath()))
{
    var testObject = theRealm.CreateObjectFromJson<StateUnique>(stream);
}

Using Json Arrays from a Android Asset Stream:

using (var theRealm = Realm.GetInstance(RealmDBTempPath()))
using (var assetStream = Application.Context.Assets.Open("States.json"))
{
    theRealm.CreateAllFromJson<State>(assetStream);
}

Using Json Arrays from a iOS Bundled Resource Stream:

using (var theRealm = Realm.GetInstance(RealmDBTempPath()))
using (var fileStream = new FileStream("./Data/States.json", FileMode.Open, FileAccess.Read))
{
    theRealm.CreateAllFromJson<State>(fileStream);
}

Note: Consult the Unit Tests for more usage details

(1)Xamarin.Forms Usage

AutoMapper does not support PCL Profile 259(2)) and thus adding this Nuget package will fail if applied to a default Xamarin.Form project.

You can change your Xamarin.From project to Profile 111, then retarget the Xamarin.Forms package, and you will be able to add the Nuget package.

See the Xamarin.Forms-based (Nuget.Test) project in the code repo as an example.

Note: Once Xamarin has full support for .NET Standard and AutoMapper releases v5.2 (3), this mess should go away.

(2) https://github.com/AutoMapper/AutoMapper/issues/1531

(3) https://github.com/AutoMapper/AutoMapper/issues/1532

Build Documention:

API Reference documention is built via the great

doxygen Doxygen/realmthread.config

Building:

xbuild or msbuild based:

xbuild /p:SolutionDir=./ /target:Clean /p:Configuration=Release   RealmJson.Extensions/RealmJson.Extensions.csproj
xbuild /p:SolutionDir=./ /target:Build /p:Configuration=Release RealmJson.Extensions/RealmJson.Extensions.csproj

Testing / NUnitLite Automation:

Xamarin.Android

adb shell am instrument -w RealmJson.Test.Droid/app.tests.TestInstrumentation

Ref: Automate Android Nunit Test

Ref: Issue 32005

Xamarin.iOS

xbuild RealmJson.Test.iOS/RealmJson.Test.iOS.csproj /p:SolutionDir=~/
xcrun simctl list
open -a Simulator --args -CurrentDeviceUDID 360D3BC6-4A6D-4B7E-A899-5C7651EC2107
xcrun simctl install booted  ./RealmJson.Test.iOS/bin/iPhoneSimulator/Debug/RealmJson.Test.iOS.app
xcrun simctl launch booted com.sushihangover.realmjson-test-ios
cat ~/Library/Logs/CoreSimulator/360D3BC6-4A6D-4B7E-A899-5C7651EC2107/system.log

Performance Testing:

There is a #if PERF within Tests.Shared.Perf.Streaming.cs that contains multple tests to evaluate streaming performance and memory overhead.

These test methods try to evaluate:

  1. Realm.Manage vs. AutoMapper performance/effeciency
  1. Upper limits of the number of RealmObjects can be used in a Realm Transaction on a mobile device.

See https://github.com/sushihangover/Realm.Json.Extensions/blob/master/Perf.md "Perf.md" for details.

License

Consult LICENSE

<head> <style> .nuget-badge code { -moz-border-radius: 5px; -webkit-border-radius: 5px; background-color: #202020; border: 4px solid silver; border-radius: 5px; box-shadow: 2px 2px 3px #6e6e6e; color: #e2e2e2; display: block; font: 1.0em 'andale mono', 'lucida console', monospace; line-height: 1.5em; overflow: auto; padding: 15px } .nuget-badge code::before { content: "PM> " } .code { -moz-border-radius: 5px; -webkit-border-radius: 5px; background-color: #202020; border: 4px solid silver; border-radius: 5px; box-shadow: 2px 2px 3px #6e6e6e; color: #e2e2e2; display: block; font: 1.0em 'andale mono', 'lucida console', monospace; line-height: 1.5em; overflow: auto; padding: 15px }

</style> </head>