<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lorenzo Pichilli</title>
    <description>The latest articles on DEV Community by Lorenzo Pichilli (@pichillilorenzo).</description>
    <link>https://dev.to/pichillilorenzo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F58536%2F9e5ce558-8882-4e50-93d5-a87aa3959f53.jpeg</url>
      <title>DEV Community: Lorenzo Pichilli</title>
      <link>https://dev.to/pichillilorenzo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pichillilorenzo"/>
    <language>en</language>
    <item>
      <title>InAppWebView: The Real Power of WebViews in Flutter</title>
      <dc:creator>Lorenzo Pichilli</dc:creator>
      <pubDate>Wed, 08 Jul 2020 13:00:26 +0000</pubDate>
      <link>https://dev.to/pichillilorenzo/inappwebview-the-real-power-of-webviews-in-flutter-h9o</link>
      <guid>https://dev.to/pichillilorenzo/inappwebview-the-real-power-of-webviews-in-flutter-h9o</guid>
      <description>&lt;p&gt;What is &lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview" rel="noopener noreferrer"&gt;&lt;code&gt;flutter_inappwebview&lt;/code&gt;&lt;/a&gt;? It's a Flutter plugin that allows you to incorporate &lt;strong&gt;WebView widgets&lt;/strong&gt; into your Flutter app, to use &lt;strong&gt;headless WebViews&lt;/strong&gt;, or to use &lt;strong&gt;In-App browsers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So, what's the difference between &lt;a href="https://pub.dev/packages/webview_flutter" rel="noopener noreferrer"&gt;&lt;code&gt;webview_flutter&lt;/code&gt;&lt;/a&gt; (Official flutter plugin) or &lt;a href="https://pub.dev/packages/flutter_webview_plugin" rel="noopener noreferrer"&gt;&lt;code&gt;flutter_webview_plugin&lt;/code&gt;&lt;/a&gt;? &lt;br&gt;
Compared to all other WebView plugins, it is &lt;strong&gt;feature-rich&lt;/strong&gt;: a lot of &lt;strong&gt;events&lt;/strong&gt;, &lt;strong&gt;methods&lt;/strong&gt;, and &lt;strong&gt;options&lt;/strong&gt; to control WebViews. Furthermore, they do not have good documentation about their API or, at least, it is not complete. Instead, every feature of flutter_inappwebview is almost all documented (just check the &lt;a href="https://pub.dev/documentation/flutter_inappwebview/latest/index.html" rel="noopener noreferrer"&gt;API Reference on pub.dev&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;In this article, I'm going to present the main classes and some examples of the &lt;code&gt;InAppWebView&lt;/code&gt; widget that people were asking about on the official &lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview" rel="noopener noreferrer"&gt;flutter_inappwebview repository&lt;/a&gt; (issue section) and on StackOverflow.&lt;/p&gt;
&lt;h2&gt;
  
  
  Main Classes Overview
&lt;/h2&gt;

&lt;p&gt;This is a list of the main classes that the plugin offers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview#inappwebview-class" rel="noopener noreferrer"&gt;InAppWebView&lt;/a&gt;: Flutter Widget for adding an &lt;strong&gt;inline native WebView&lt;/strong&gt; integrated into the flutter widget tree.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview#contextmenu-class" rel="noopener noreferrer"&gt;ContextMenu&lt;/a&gt;: This class represents the WebView context menu.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview#headlessinappwebview-class" rel="noopener noreferrer"&gt;HeadlessInAppWebView&lt;/a&gt;: Class that represents a WebView in headless mode. It can be used to run a WebView in background without attaching an &lt;code&gt;InAppWebView&lt;/code&gt; to the widget tree.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview#inappbrowser-class" rel="noopener noreferrer"&gt;InAppBrowser&lt;/a&gt;: In-App Browser using native WebView.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview#chromesafaribrowser-class" rel="noopener noreferrer"&gt;ChromeSafariBrowser&lt;/a&gt;: In-App Browser using &lt;a href="https://developer.android.com/reference/android/support/customtabs/package-summary" rel="noopener noreferrer"&gt;Chrome Custom Tabs&lt;/a&gt; on Android / &lt;a href="https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller" rel="noopener noreferrer"&gt;SFSafariViewController&lt;/a&gt; on iOS.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview#inapplocalhostserver-class" rel="noopener noreferrer"&gt;InAppLocalhostServer&lt;/a&gt;: This class allows you to create a simple server on &lt;code&gt;http://localhost:[port]/&lt;/code&gt;. The default &lt;code&gt;port&lt;/code&gt; value is &lt;code&gt;8080&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview#cookiemanager-class" rel="noopener noreferrer"&gt;CookieManager&lt;/a&gt;: This class implements a singleton object (shared instance) that manages the cookies used by WebView instances.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview#httpauthcredentialdatabase-class" rel="noopener noreferrer"&gt;HttpAuthCredentialDatabase&lt;/a&gt;: This class implements a singleton object (shared instance) which manages the shared HTTP auth credentials cache.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview#webstoragemanager-class" rel="noopener noreferrer"&gt;WebStorageManager&lt;/a&gt;: This class implements a singleton object (shared instance) which manages the web storage used by WebView instances.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this article, I'm going to show in particular the &lt;code&gt;InAppWebView&lt;/code&gt; widget, that is the most used/requested one.&lt;/p&gt;
&lt;h3&gt;
  
  
  InAppWebView Widget
&lt;/h3&gt;

&lt;p&gt;Adding the &lt;code&gt;InAppWebView&lt;/code&gt; widget into your app is very simple. It's just a widget like any other Flutter widget: &lt;code&gt;InAppWebView(initialUrl: 'https://github.com/flutter')&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: To use it on iOS, you need to opt-in for the embedded views preview by adding a boolean property to the app's &lt;code&gt;Info.plist&lt;/code&gt; file, with the key &lt;code&gt;io.flutter.embedded_views_preview&lt;/code&gt; and the value &lt;code&gt;YES&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This widget has a set of initial attributes that you can use to initialize the WebView:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;initialUrl&lt;/strong&gt;: Initial URL that will be loaded.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;initialOptions&lt;/strong&gt;: Initial WebView options that will be used.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;gestureRecognizers&lt;/strong&gt;: specifies which gestures should be consumed by the WebView;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;initialData&lt;/strong&gt;: Initial InAppWebViewInitialData that will be loaded, such as an HTML string.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;initialFile&lt;/strong&gt;: Initial asset file that will be loaded (check the “&lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview#load-a-file-inside-assets-folder" rel="noopener noreferrer"&gt;&lt;em&gt;Load a file inside assets folder&lt;/em&gt;&lt;/a&gt;” Section).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;initialHeaders&lt;/strong&gt;: Initial headers that will be used.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;contextMenu&lt;/strong&gt;: Context menu which contains custom menu items.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The list of all available WebView options is quite long, for example, you can enable/disable JavaScript using the javascriptEnabled option or enable/disable cache using the cacheEnabled option. The full list of all options is available &lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview#inappwebview-options" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Use InAppWebViewController to control your WebView
&lt;/h3&gt;

&lt;p&gt;Instead, to control the WebView, you have the &lt;code&gt;InAppWebViewController&lt;/code&gt; class. This controller is returned by the &lt;code&gt;onWebViewCreated&lt;/code&gt; callback when the WebView is ready to be used.&lt;br&gt;
Through it, you can control your WebView or access its properties, such as the current URL using &lt;code&gt;getUrl&lt;/code&gt; method. Other methods, for example, are &lt;code&gt;loadUrl&lt;/code&gt; to load a new URL, &lt;code&gt;postUrl&lt;/code&gt; to load a given URL with custom data using POST method, &lt;code&gt;evaluateJavascript&lt;/code&gt; to evaluate JavaScript code into the WebView, and to get the result of the evaluation, &lt;code&gt;takeScreenshot&lt;/code&gt; to take the screenshot (in PNG format) of the WebView’s visible viewport, &lt;code&gt;getCertificate&lt;/code&gt; to get the &lt;strong&gt;SSL certificate&lt;/strong&gt; for the main top-level page or &lt;code&gt;null&lt;/code&gt; if there is no certificate. The full list of all methods you can use is quite long and available &lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview#inappwebviewcontroller-methods" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  InAppWebView Events
&lt;/h3&gt;

&lt;p&gt;The InAppWebView widget offers a variety of events! Here’s a few of them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;onLoadStart&lt;/strong&gt;: event fired when the WebView starts to load an URL;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onLoadStop&lt;/strong&gt;: event fired when the WebView finishes loading an URL;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onLoadHttpError&lt;/strong&gt;: event fired when the WebView main page receives an HTTP error;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onConsoleMessage&lt;/strong&gt;: event fired when the WebView receives a JavaScript console message (such as &lt;code&gt;console.log&lt;/code&gt;, &lt;code&gt;console.error&lt;/code&gt;, etc.);&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;shouldOverrideUrlLoading&lt;/strong&gt;: gives the host application a chance to take control when a URL is about to be loaded in the current WebView;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onDownloadStart&lt;/strong&gt;: event fired when WebView recognizes a downloadable file;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onReceivedHttpAuthRequest&lt;/strong&gt;: event fired when the WebView received an HTTP authentication request. The default behavior is to cancel the request;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onReceivedServerTrustAuthRequest&lt;/strong&gt;: event fired when the WebView need to perform server trust authentication (certificate validation);&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onPrint&lt;/strong&gt;: event fired when &lt;code&gt;window.print()&lt;/code&gt; is called from JavaScript side;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onCreateWindow&lt;/strong&gt;: event fired when the InAppWebView requests the host application to create a new window, for example when trying to open a link with &lt;code&gt;target="_blank"&lt;/code&gt; or when &lt;code&gt;window.open()&lt;/code&gt; is called by JavaScript side;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and &lt;strong&gt;many many more&lt;/strong&gt;! I recommend checking the API Reference to get more details. As for the WebView options and methods, the full list of all WebView events is quite long and available &lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview#inappwebview-events" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  InAppWebView Simple Example
&lt;/h3&gt;

&lt;p&gt;Here is a simple example that shows an &lt;code&gt;InAppWebView&lt;/code&gt; widget, its current URL, and 3 buttons: one to go back, one to go forward, and another one to reload the current page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fekyytgezb0w4o6tva7ft.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fekyytgezb0w4o6tva7ft.gif" alt="InAppWebView example."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the full code example:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  JavaScript Handlers (Channels)
&lt;/h3&gt;

&lt;p&gt;You can communicate with the JavaScript side and vice-versa. To add a JavaScript handler, you can use &lt;code&gt;_webViewController.addJavaScriptHandler&lt;/code&gt; method, where you define the &lt;code&gt;handlerName&lt;/code&gt; and a &lt;code&gt;callback&lt;/code&gt; to be invoked when it is called by the JavaScript side. The &lt;code&gt;callback&lt;/code&gt; can return data to be sent on the JavaScript side.&lt;/p&gt;

&lt;p&gt;Instead, on the JavaScript side, to execute the callback handler and send data to Flutter, you need to use &lt;code&gt;window.flutter_inappwebview.callHandler(handlerName &amp;lt;String&amp;gt;, ...args)&lt;/code&gt; method, where &lt;code&gt;handlerName&lt;/code&gt; is a string that represents the handler name that your calling and &lt;code&gt;args&lt;/code&gt; are optional arguments that you can send to the Flutter side.&lt;/p&gt;

&lt;p&gt;In order to call &lt;code&gt;window.flutter_inappwebview.callHandler(handlerName &amp;lt;String&amp;gt;, ...args)&lt;/code&gt; properly, you need to wait and listen to the JavaScript event &lt;code&gt;flutterInAppWebViewPlatformReady&lt;/code&gt;. This event will be dispatched as soon as the platform (Android or iOS) is ready to handle the &lt;code&gt;callHandler&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;Here is an example:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  WebRTC in InAppWebView
&lt;/h3&gt;

&lt;p&gt;At this moment, &lt;strong&gt;WebRTC&lt;/strong&gt; is supported only on Android, because, unfortunately, on iOS &lt;code&gt;WKWebView&lt;/code&gt; doesn’t implement all the WebRTC API (you can follow this issue: &lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview/issues/200" rel="noopener noreferrer"&gt;&lt;strong&gt;#200&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;I’m going to show an example using &lt;a href="https://appr.tc/" rel="noopener noreferrer"&gt;https://appr.tc/&lt;/a&gt; to test WebRTC feature. It’s a video chat demo app based on WebRTC (&lt;a href="https://github.com/webrtc/apprtc" rel="noopener noreferrer"&gt;https://github.com/webrtc/apprtc&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;To request permissions about the camera and microphone, you can use the &lt;a href="https://pub.dev/packages/permission_handler" rel="noopener noreferrer"&gt;permission_handler&lt;/a&gt; plugin. Also, you need to set the WebView option &lt;code&gt;mediaPlaybackRequiresUserGesture&lt;/code&gt; to &lt;code&gt;false&lt;/code&gt; in order to autoplay HTML5 audio and video.&lt;/p&gt;

&lt;p&gt;Furthermore, on Android, you need to implement the &lt;code&gt;androidOnPermissionRequest&lt;/code&gt; event (it’s an Android-specific event), that is an event fired when the WebView is requesting permission to access a specific resource (that is the Android native &lt;a href="https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest)" rel="noopener noreferrer"&gt;WebChromeClient.onPermissionRequest event&lt;/a&gt;). In this case, this event is used to grant permissions for the WebRTC API. Also, you need to add these permissions in the &lt;code&gt;AndroidManifest.xml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;uses-permission&lt;/span&gt; &lt;span class="na"&gt;android:name=&lt;/span&gt;&lt;span class="s"&gt;"android.permission.INTERNET"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;uses-permission&lt;/span&gt; &lt;span class="na"&gt;android:name=&lt;/span&gt;&lt;span class="s"&gt;"android.permission.CAMERA"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;uses-permission&lt;/span&gt; &lt;span class="na"&gt;android:name=&lt;/span&gt;&lt;span class="s"&gt;"android.permission.RECORD_AUDIO"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;uses-permission&lt;/span&gt; &lt;span class="na"&gt;android:name=&lt;/span&gt;&lt;span class="s"&gt;"android.permission.MODIFY_AUDIO_SETTINGS"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;uses-permission&lt;/span&gt; &lt;span class="na"&gt;android:name=&lt;/span&gt;&lt;span class="s"&gt;"android.permission.VIDEO_CAPTURE"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;uses-permission&lt;/span&gt; &lt;span class="na"&gt;android:name=&lt;/span&gt;&lt;span class="s"&gt;"android.permission.AUDIO_CAPTURE"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fn48m8zaxfk9jawd606zy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fn48m8zaxfk9jawd606zy.gif" alt="WebRTC example."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the full code example:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h3&gt;
  
  
  How to enable download files in InAppWebView
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;InAppWebView&lt;/code&gt; can recognize downloadable files in both Android and iOS platforms. To be able to recognize downloadable files, you need to set the &lt;code&gt;useOnDownloadStart: true&lt;/code&gt; option, and then you can listen to the &lt;code&gt;onDownloadStart&lt;/code&gt; event.&lt;/p&gt;

&lt;p&gt;On Android you need to add write permission inside your &lt;code&gt;AndroidManifest.xml&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;uses-permission&lt;/span&gt; &lt;span class="na"&gt;android:name=&lt;/span&gt;&lt;span class="s"&gt;"android.permission.WRITE_EXTERNAL_STORAGE"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then, you need to ask permission using the &lt;a href="https://pub.dev/packages/permission_handler" rel="noopener noreferrer"&gt;permission_handler&lt;/a&gt; plugin. Instead, to effectively download your file, you can use the &lt;a href="https://pub.dev/packages/flutter_downloader" rel="noopener noreferrer"&gt;flutter_downloader&lt;/a&gt; plugin.&lt;br&gt;
Here is a complete example using &lt;a href="http://ovh.net/files/" rel="noopener noreferrer"&gt;http://ovh.net/files/&lt;/a&gt; (in particular, the &lt;a href="http://ovh.net/files/1Mio.dat" rel="noopener noreferrer"&gt;http://ovh.net/files/1Mio.dat&lt;/a&gt; as URL) to test the download:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;As you can see, I’m using also the &lt;a href="https://pub.dev/packages/path_provider" rel="noopener noreferrer"&gt;path_provider&lt;/a&gt; plugin to get the folder where I want to save the file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Allow Self-signed SSL Certificates
&lt;/h3&gt;

&lt;p&gt;To allow self-signed SSL certificates, you can use the &lt;code&gt;onReceivedServerTrustAuthRequest&lt;/code&gt; event and simply return to proceed with the request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="nl"&gt;onReceivedServerTrustAuthRequest:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;challenge&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ServerTrustAuthResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;action:&lt;/span&gt; &lt;span class="n"&gt;ServerTrustAuthResponseAction&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;PROCEED&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  How to manage popup windows opened with target=”_blank” or “window.open”
&lt;/h3&gt;

&lt;p&gt;To manage popup windows when a user clicks on a link with &lt;code&gt;target="_blank"&lt;/code&gt; or through JavaScript code using &lt;code&gt;window.open&lt;/code&gt;, you can use the &lt;code&gt;onCreateWindow&lt;/code&gt; event. On Android, to be able to allow this event, you need to set the &lt;code&gt;supportMultipleWindows&lt;/code&gt; option to &lt;code&gt;true&lt;/code&gt;. Also, in order to be able to allow the usage of JavaScript, you need to set the &lt;code&gt;javaScriptCanOpenWindowsAutomatically&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you want to manage these requests, you should return &lt;code&gt;true&lt;/code&gt; from this event, otherwise, the default implementation of this event does nothing and hence returns &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;CreateWindowRequest&lt;/code&gt; represents the navigation request which contains a &lt;code&gt;windowId&lt;/code&gt; that can be used to create, for example, a new &lt;code&gt;InAppWebView&lt;/code&gt; instance. This &lt;code&gt;windowId&lt;/code&gt; is used by the native code to map the request and the WebView to be used to manage that request.&lt;/p&gt;

&lt;p&gt;Also, &lt;code&gt;CreateWindowRequest&lt;/code&gt; contains the &lt;code&gt;url&lt;/code&gt; of the request (on Android, if the popup is opened using JavaScript with &lt;code&gt;window.open&lt;/code&gt;, it will be &lt;code&gt;null&lt;/code&gt;), but if you need to maintain the Window JavaScript object reference (created using window.open method), for example, to call &lt;code&gt;window.close&lt;/code&gt; method, then you should create the new WebView with the &lt;code&gt;windowId&lt;/code&gt;, without using the &lt;code&gt;url&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here is a simple example that shows an &lt;code&gt;AlertDialog&lt;/code&gt; when the user clicks on the link:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhqojjmcik63f8phbhdo0.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhqojjmcik63f8phbhdo0.gif" alt="onCreateWindow Event - Popup window example."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Manage platform URLs such as whatsapp:, fb:, tel:, mailto:, etc.
&lt;/h3&gt;

&lt;p&gt;Generally, a WebView knows nothing on how to manage &lt;code&gt;whatsapp:&lt;/code&gt;, &lt;code&gt;tel:&lt;/code&gt; or &lt;code&gt;fb:&lt;/code&gt; protocol/scheme. To capture the requests made with these custom protocols/schemes, you can use the &lt;code&gt;shouldOverrideUrlLoading&lt;/code&gt; event (you need to enable it with &lt;code&gt;useShouldOverrideUrlLoading: true&lt;/code&gt; option).&lt;/p&gt;

&lt;p&gt;This way you can cancel the request made for the WebView and, instead, open the App, for example, using the &lt;a href="https://pub.dev/packages/url_launcher" rel="noopener noreferrer"&gt;url_launcher&lt;/a&gt; plugin:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="nl"&gt;initialOptions:&lt;/span&gt; &lt;span class="n"&gt;InAppWebViewGroupOptions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;crossPlatform:&lt;/span&gt; &lt;span class="n"&gt;InAppWebViewOptions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;debuggingEnabled:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;useShouldOverrideUrlLoading:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="nl"&gt;shouldOverrideUrlLoading:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;uri&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;Uri&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"http"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"https"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"file"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;"chrome"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"javascript"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;"about"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;scheme&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;canLaunch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Launch the App&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;launch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="c1"&gt;// and cancel the request&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ShouldOverrideUrlLoadingAction&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;CANCEL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ShouldOverrideUrlLoadingAction&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ALLOW&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Manage WebView Cookies
&lt;/h3&gt;

&lt;p&gt;To manage WebView cookies, you can use the &lt;code&gt;CookieManager&lt;/code&gt; class, which implements a singleton object (shared instance). On Android, it is implemented using the &lt;a href="https://developer.android.com/reference/android/webkit/CookieManager" rel="noopener noreferrer"&gt;CookieManager&lt;/a&gt; class. On iOS, it is implemented using the &lt;a href="https://developer.apple.com/documentation/webkit/wkhttpcookiestore" rel="noopener noreferrer"&gt;WKHTTPCookieStore&lt;/a&gt; class.&lt;/p&gt;

&lt;p&gt;Here is an example of how to set a cookie:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;CookieManager&lt;/span&gt; &lt;span class="n"&gt;_cookieManager&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CookieManager&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;expiresDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
    &lt;span class="n"&gt;DateTime&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Duration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;days:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;millisecondsSinceEpoch&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;_cookieManager&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setCookie&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;url:&lt;/span&gt; &lt;span class="s"&gt;"https://flutter.dev/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;name:&lt;/span&gt; &lt;span class="s"&gt;"session"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;value:&lt;/span&gt; &lt;span class="s"&gt;"54th5hfdcfg34"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;domain:&lt;/span&gt; &lt;span class="s"&gt;".flutter.dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;expiresDate:&lt;/span&gt; &lt;span class="n"&gt;expiresDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;isSecure:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Custom context menus
&lt;/h3&gt;

&lt;p&gt;You can customize WebView’s context menu adding custom menu items, and/or hiding the default system menu items. For each custom menu item, you can declare a callback &lt;code&gt;action&lt;/code&gt; to be invoked when the user clicks on it. As an example, I will add a custom menu item named &lt;code&gt;Special&lt;/code&gt; and I will define a callback action that shows a JavaScript &lt;code&gt;window.alert&lt;/code&gt; to the user with the text selected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft1u9w8icyge7fw4n64c2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft1u9w8icyge7fw4n64c2.gif" alt="Custom menu item example."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the full code example:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In this article, I made a little introduction to the &lt;a href="https://github.com/pichillilorenzo/flutter_inappwebview" rel="noopener noreferrer"&gt;flutter_inappwebview&lt;/a&gt; plugin, in particular, about the &lt;code&gt;InAppWebView&lt;/code&gt; widget. The plugin is in continuous development (at the time of this writing, the latest release is &lt;code&gt;4.0.0+4&lt;/code&gt;) and I recommend you check out the API Reference to find out all the features. For any new feature request/bug fix, you can use the issue section of the repository.&lt;/p&gt;

&lt;p&gt;The next article will be on how to implement a &lt;strong&gt;Full-Featured Browser&lt;/strong&gt; using this plugin.&lt;/p&gt;

&lt;p&gt;That’s all for today! I hope it has opened new use cases for your Flutter apps.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>webview</category>
      <category>flutterwebview</category>
      <category>inappbrowser</category>
    </item>
    <item>
      <title>Jackson-js: Examples for client (Angular) and server (Node.js) side (Part 2)</title>
      <dc:creator>Lorenzo Pichilli</dc:creator>
      <pubDate>Wed, 13 May 2020 16:03:08 +0000</pubDate>
      <link>https://dev.to/pichillilorenzo/jackson-js-examples-for-client-angular-and-server-node-js-side-part-2-128n</link>
      <guid>https://dev.to/pichillilorenzo/jackson-js-examples-for-client-angular-and-server-node-js-side-part-2-128n</guid>
      <description>&lt;p&gt;&lt;em&gt;This is the second part of a two-part series. You should read the first part “&lt;a href="https://dev.to/pichillilorenzo/jackson-js-powerful-javascript-decorators-to-serialize-deserialize-objects-into-json-and-vice-versa-part-1-5484"&gt;Jackson-js: Powerful JavaScript decorators to serialize/deserialize objects into JSON and vice versa (Part 1)&lt;/a&gt;”.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In this article, I will give a simple example using the &lt;a href="https://github.com/pichillilorenzo/jackson-js"&gt;&lt;code&gt;jackson-js&lt;/code&gt;&lt;/a&gt; library with Angular 9 for the client side and two examples for the server side: one using Node.js + &lt;a href="http://expressjs.com/"&gt;Express&lt;/a&gt; + SQLite3 (with &lt;a href="https://sequelize.org/"&gt;Sequelize 5&lt;/a&gt;) and another one using Node.js + &lt;a href="https://github.com/strongloop/loopback-next"&gt;LoopBack 4&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Full code examples can be found in &lt;a href="https://github.com/pichillilorenzo/jackson-js-examples"&gt;this repository&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Client side: Angular 9
&lt;/h2&gt;

&lt;p&gt;For the client side, we will create a very basic Angular 9 application consisting of 2 models (&lt;code&gt;Writer&lt;/code&gt; and &lt;code&gt;Book&lt;/code&gt;), 2 services to communicate with the server side, and a home component that will call these 2 services.&lt;/p&gt;

&lt;h3&gt;
  
  
  Models
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Writer model&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
&lt;strong&gt;Book model&lt;/strong&gt;:&lt;br&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  Services
&lt;/h3&gt;

&lt;p&gt;Services that will be used to get/push data from/to the server side.&lt;br&gt;
&lt;strong&gt;Writer Service&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
&lt;strong&gt;Book Service&lt;/strong&gt;:&lt;br&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  Home Component
&lt;/h3&gt;

&lt;p&gt;A very basic component that will be used to call each method of each service and to print the responses data to the browser console.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Server side: Node.js + Express + SQLite3 (with Sequelize 5)
&lt;/h2&gt;

&lt;p&gt;For this case, we will implement a simple Node.js &lt;a href="http://expressjs.com/"&gt;Express&lt;/a&gt; application using an in-memory SQLite 3 database (with &lt;a href="https://sequelize.org/"&gt;Sequelize 5&lt;/a&gt;), consisting of 2 entities (Writer and Book). This Express application will offer endpoints used by the client side to get/add data from/to the database. Also, it will have 2 Jackson Views has an example: &lt;code&gt;ProfileViews.public&lt;/code&gt; and &lt;code&gt;ProfileViews.registered&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Models
&lt;/h3&gt;

&lt;p&gt;Because each class model extends the Sequelize.Model class, we need to ignore its enumerable properties using the &lt;code&gt;@JsonIgnoreProperties&lt;/code&gt; decorator, otherwise, serialization won't work properly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Writer model&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
As we can see, the writer model has a static creator method named buildFromJson decorated with the &lt;code&gt;@JsonCreator&lt;/code&gt; decorator. This method will be used during deserialization in order to create an instance of the Writer class model using Sequelize 5 API.

&lt;p&gt;Also, I defined a getter method for the books property using &lt;code&gt;@JsonGetter&lt;/code&gt; in order to get the associated data (one-to-many relationship with &lt;code&gt;Book&lt;/code&gt;) through the Sequelize &lt;code&gt;get()&lt;/code&gt; method. Without this, during serialization, the &lt;code&gt;books&lt;/code&gt; property will be empty. Another way is to call the Sequelize &lt;code&gt;get()&lt;/code&gt; or &lt;code&gt;toJSON()&lt;/code&gt; method for each model that needs to be serialized before serialization. This is needed because Sequelize wraps all it’s return values in a virtual object that contains metadata, so we unwrap them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Book model&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
Same as &lt;code&gt;Writer&lt;/code&gt;, we have a static creator method used to build the Book instance and a getter method for the writer property. Also, in the &lt;code&gt;@JsonIgnoreProperties&lt;/code&gt; decorator, I added the &lt;code&gt;writerId&lt;/code&gt; property (that is automatically added by Sequelize) in order to exclude it from the generated JSON content.
&lt;h2&gt;
  
  
  Server side: Node.js + LoopBack 4
&lt;/h2&gt;

&lt;p&gt;Instead, for this case, we will implement a simple &lt;a href="https://github.com/strongloop/loopback-next"&gt;LoopBack 4&lt;/a&gt; application using a file data source as the database. This application will offer endpoints used by the client side to get/add data from/to the database. Also here, it will have 2 Jackson Views has an example: &lt;code&gt;ProfileViews.public&lt;/code&gt; and &lt;code&gt;ProfileViews.registered&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Models
&lt;/h3&gt;

&lt;p&gt;LoopBack 4 Entity class doesn't wrap our entities, so we don't need to use &lt;code&gt;@JsonIgnoreProperties&lt;/code&gt; decorator like on Sequelize.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Writer model&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Book model&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  LoopBack Custom “object-mapper” Interceptor
&lt;/h3&gt;

&lt;p&gt;LoopBack gives us the ability to create custom interceptors. In this case, I created a global interceptor called &lt;code&gt;object-mapper&lt;/code&gt; that will be used by the controllers to read and write JSON content using the &lt;code&gt;jackson-js&lt;/code&gt; library.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Jackson Context Groups
&lt;/h2&gt;

&lt;p&gt;For both server side examples, I defined 2 context groups: &lt;code&gt;writerContextApi&lt;/code&gt; and &lt;code&gt;bookContextApi&lt;/code&gt;. They are used to enable/disable specific decorators based on which API endpoint the client is calling.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;writerContextApi&lt;/code&gt;: it is used when the client is calling &lt;code&gt;/writers/*&lt;/code&gt; endpoints to enable the &lt;code&gt;@JsonManagedReference&lt;/code&gt; decorator and disable the &lt;code&gt;@JsonIgnoreProperties&lt;/code&gt; decorator on the &lt;code&gt;Writer.books&lt;/code&gt; property and to enable the &lt;code&gt;@JsonBackReference&lt;/code&gt; decorator on the &lt;code&gt;Book.writer&lt;/code&gt; property;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bookContextApi&lt;/code&gt;: it is used when the client is calling &lt;code&gt;/books/*&lt;/code&gt; endpoints to enable the &lt;code&gt;@JsonIgnoreProperties&lt;/code&gt; decorator on the &lt;code&gt;Writer.books&lt;/code&gt; property.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  RESTful API Endpoints available
&lt;/h2&gt;

&lt;p&gt;Both servers run at &lt;code&gt;http://localhost:8000&lt;/code&gt; and, for each one, I created a function named &lt;code&gt;initDB&lt;/code&gt; that will initialize the database with fake data at server startup.&lt;/p&gt;

&lt;p&gt;Endpoints are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/writers/public&lt;/code&gt;: get (“GET”) all writers (with books) using &lt;code&gt;ProfileViews.public&lt;/code&gt; Jackson view;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/writers&lt;/code&gt;: get (“GET”) all writers (with books) or add (“POST”) a new writer;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/books/public&lt;/code&gt;: get (“GET”) all books (each one with its writer) using &lt;code&gt;ProfileViews.public&lt;/code&gt; Jackson view;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/books&lt;/code&gt;: get (“GET”) all books (each one with its writer) or add (“POST”) a new book.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c9giAXLX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bo3fwig817eazik5c2li.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c9giAXLX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bo3fwig817eazik5c2li.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
The parsed response of the client side after calling “/writers/public” endpoint of the Node.js + LoopBack 4 server.



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vm0nIygD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/donxiehbh0ijsl65xxrx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vm0nIygD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/donxiehbh0ijsl65xxrx.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
The parsed response of the client side after calling “/books” endpoint of the Node.js + Express + SQLite3 (with Sequelize 5) server.



</description>
      <category>decorators</category>
      <category>javascript</category>
      <category>jsonparse</category>
      <category>jsonstringify</category>
    </item>
    <item>
      <title>Jackson-js: Powerful JavaScript decorators to serialize/deserialize objects into JSON and vice versa (Part 1)</title>
      <dc:creator>Lorenzo Pichilli</dc:creator>
      <pubDate>Wed, 13 May 2020 16:02:49 +0000</pubDate>
      <link>https://dev.to/pichillilorenzo/jackson-js-powerful-javascript-decorators-to-serialize-deserialize-objects-into-json-and-vice-versa-part-1-5484</link>
      <guid>https://dev.to/pichillilorenzo/jackson-js-powerful-javascript-decorators-to-serialize-deserialize-objects-into-json-and-vice-versa-part-1-5484</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpu4cd5n67pxh5f2awb8w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpu4cd5n67pxh5f2awb8w.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
JSON logo



&lt;p&gt;After many hours of development, I finally released the first version of the &lt;a href="https://github.com/pichillilorenzo/jackson-js" rel="noopener noreferrer"&gt;&lt;code&gt;jackson-js&lt;/code&gt;&lt;/a&gt; library. As the name implies, &lt;a href="https://github.com/pichillilorenzo/jackson-js" rel="noopener noreferrer"&gt;&lt;code&gt;jackson-js&lt;/code&gt;&lt;/a&gt; decorators are heavily inspired by the Java annotations of the famous Java &lt;a href="https://github.com/FasterXML/jackson" rel="noopener noreferrer"&gt;FasterXML/jackson library&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can install it using &lt;code&gt;npm install —-save jackson-js&lt;/code&gt; and it can be used on both &lt;strong&gt;client&lt;/strong&gt; (browser) and &lt;strong&gt;server&lt;/strong&gt; (Node.js) side.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this library? What’s the difference between using this library instead of &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse" rel="noopener noreferrer"&gt;&lt;code&gt;JSON.parse&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify" rel="noopener noreferrer"&gt;&lt;code&gt;JSON.stringify&lt;/code&gt;&lt;/a&gt;?
&lt;/h2&gt;

&lt;p&gt;For simple cases, you don't need this library of course, you can just use &lt;code&gt;JSON.parse&lt;/code&gt; and &lt;code&gt;JSON.stringify&lt;/code&gt; to serialize/deserialize JSON.&lt;/p&gt;

&lt;p&gt;With &lt;a href="https://github.com/pichillilorenzo/jackson-js" rel="noopener noreferrer"&gt;&lt;code&gt;jackson-js&lt;/code&gt;&lt;/a&gt;, you can easily manipulate your JavaScript objects/values serialization/deserialization using decorators such as &lt;code&gt;@JsonProperty()&lt;/code&gt;, &lt;code&gt;@JsonFormat()&lt;/code&gt;, &lt;code&gt;@JsonIgnore()&lt;/code&gt;, and more. However, this library uses &lt;code&gt;JSON.parse&lt;/code&gt; and &lt;code&gt;JSON.stringify&lt;/code&gt; under the hood.&lt;/p&gt;

&lt;p&gt;Furthermore: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;it not only deserialize JSON text into a JavaScript object, it also converts it into an &lt;strong&gt;instance of the class&lt;/strong&gt; specified in the &lt;code&gt;context&lt;/code&gt; option (similar packages are: &lt;a href="https://github.com/typestack/class-transformer" rel="noopener noreferrer"&gt;class-transformer&lt;/a&gt; and &lt;a href="https://github.com/JohnWeisz/TypedJSON" rel="noopener noreferrer"&gt;TypedJSON&lt;/a&gt;); instead, with &lt;code&gt;JSON.parse&lt;/code&gt; you will get just a simple plain (literal) JavaScript object (just &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" rel="noopener noreferrer"&gt;&lt;code&gt;Object&lt;/code&gt;&lt;/a&gt; type);&lt;/li&gt;
&lt;li&gt;it supports more advanced Object concepts such as &lt;strong&gt;polymorphism&lt;/strong&gt; and &lt;strong&gt;Object identity&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;it supports &lt;strong&gt;cyclic object&lt;/strong&gt; serialization/deserialization;&lt;/li&gt;
&lt;li&gt;it supports serialization/deserialization of other native JavaScript types: &lt;code&gt;Map&lt;/code&gt;, &lt;code&gt;Set&lt;/code&gt;, &lt;code&gt;BigInt&lt;/code&gt;, Typed Arrays (such as &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array" rel="noopener noreferrer"&gt;&lt;code&gt;Int8Array&lt;/code&gt;&lt;/a&gt;);&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This library can be useful in more complex cases, for example when you want to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;manipulate JSON in depth;&lt;/li&gt;
&lt;li&gt;restore a JavaScript type (a similar package is &lt;a href="https://github.com/typestack/class-transformer" rel="noopener noreferrer"&gt;class-transformer&lt;/a&gt;); &lt;/li&gt;
&lt;li&gt;preserve type information (using polymorphic type handling decorators: &lt;code&gt;@JsonTypeInfo&lt;/code&gt;, &lt;code&gt;@JsonSubTypes&lt;/code&gt;, and &lt;code&gt;@JsonTypeName&lt;/code&gt;. A similar package is &lt;a href="https://github.com/JohnWeisz/TypedJSON" rel="noopener noreferrer"&gt;TypedJSON&lt;/a&gt;);&lt;/li&gt;
&lt;li&gt;hide some properties for certain HTTP endpoints or some other external service;&lt;/li&gt;
&lt;li&gt;have different JSON response for some external application or manage different JSON data coming from other application (for example you need to communicate with a Spring Boot application that uses different JSON Schema for the same model or with other applications made with Python, PHP, etc...);&lt;/li&gt;
&lt;li&gt;manage cyclic references;&lt;/li&gt;
&lt;li&gt;manage other JavaScript native types such as Maps and Sets;&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most of the use cases of the Java &lt;a href="https://github.com/FasterXML/jackson" rel="noopener noreferrer"&gt;FasterXML/jackson&lt;/a&gt; annotations are similar or equal.&lt;/p&gt;

&lt;p&gt;In this article, I will present a basic example for each decorator.&lt;/p&gt;

&lt;h2&gt;
  
  
  ObjectMapper, JsonParser and JsonStringifier classes
&lt;/h2&gt;

&lt;p&gt;The main classes that &lt;a href="https://github.com/pichillilorenzo/jackson-js" rel="noopener noreferrer"&gt;&lt;code&gt;jackson-js&lt;/code&gt;&lt;/a&gt; offers to serialize and deserialize JavaScript objects are: &lt;code&gt;ObjectMapper&lt;/code&gt;, &lt;code&gt;JsonStringifier&lt;/code&gt; and &lt;code&gt;JsonParser&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  ObjectMapper
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;ObjectMapper&lt;/code&gt; provides functionality for both reading and writing JSON and applies &lt;code&gt;jackson-js&lt;/code&gt; &lt;strong&gt;decorators&lt;/strong&gt;. It will use instances of &lt;code&gt;JsonParser&lt;/code&gt; and &lt;code&gt;JsonStringifier&lt;/code&gt; for implementing actual reading/writing of JSON. It has two methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;stringify(obj: T, context?: JsonStringifierContext): string&lt;/code&gt;: a method for serializing a JavaScript object or a value to a JSON string with &lt;strong&gt;decorators&lt;/strong&gt; applied;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;parse(text: string, context?: JsonParserContext): T&lt;/code&gt;: a method for deserializing a JSON string into a JavaScript object/value (of type &lt;code&gt;T&lt;/code&gt;, based on the context given) with &lt;strong&gt;decorators&lt;/strong&gt; applied.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  JsonParser
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;JsonParser&lt;/code&gt; provides functionality for writing JSON and applies &lt;code&gt;jackson-js&lt;/code&gt; &lt;strong&gt;decorators&lt;/strong&gt;. The main methods are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;parse(text: string, context?: JsonParserContext): T&lt;/code&gt; : a method for deserializing a JSON string into a JavaScript object/value (of type &lt;code&gt;T&lt;/code&gt;, based on the context given) with &lt;strong&gt;decorators&lt;/strong&gt; applied;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;transform(value: any, context?: JsonParserContext): any&lt;/code&gt; : a method for applying &lt;code&gt;jackson-js&lt;/code&gt; &lt;strong&gt;decorators&lt;/strong&gt; to a JavaScript object/value parsed. It returns a JavaScript object/value with decorators applied.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  JsonStringifier
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;JsonStringifier&lt;/code&gt; provides functionality for reading JSON and applies &lt;code&gt;jackson-js&lt;/code&gt; &lt;strong&gt;decorators&lt;/strong&gt;. The main methods are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;stringify(obj: T, context?: JsonStringifierContext): string&lt;/code&gt;: a method for serializing a JavaScript object or a value to a JSON string with &lt;strong&gt;decorators&lt;/strong&gt; applied;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;transform(value: any, context?: JsonStringifierContext): any&lt;/code&gt;: a method for applying &lt;code&gt;jackson-js&lt;/code&gt; &lt;strong&gt;decorators&lt;/strong&gt; to a JavaScript object/value. It returns a JavaScript object/value with decorators applied and ready to be JSON serialized.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Decorators
&lt;/h2&gt;

&lt;p&gt;Before we go on, I need to say that the most important decorators are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@JsonProperty()&lt;/code&gt;: each class property (or its getter/setter) must be decorated with this decorator, otherwise deserialization and serialization will not work properly! That's because, for example, given a JavaScript class, there isn't any way or API (such as &lt;a href="https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/package-summary.html" rel="noopener noreferrer"&gt;Reflection API for Java&lt;/a&gt;) to get for sure all the class properties; also because, sometimes, compilers such as &lt;a href="https://www.typescriptlang.org/" rel="noopener noreferrer"&gt;TypeScript&lt;/a&gt; and &lt;a href="https://babeljs.io/" rel="noopener noreferrer"&gt;Babel&lt;/a&gt;, can strip class properties after compilation from the class properties declaration;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@JsonClassType()&lt;/code&gt;: this decorator, instead, is used to define the type of a class property or method parameter. This information is used during serialization and, more important, during deserialization to know about &lt;strong&gt;the type of a property/parameter&lt;/strong&gt;. This is necessary because JavaScript isn't a strongly-typed programming language, so, for example, during deserialization, without the usage of this decorator, there isn't any way to know the specific type of a class property, such as a &lt;code&gt;Date&lt;/code&gt; or a custom Class type.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Later, they will be explained in more detail.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonAlias
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;@JsonAlias&lt;/code&gt; decorator defines one or more alternative names for a property during deserialization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonalias" rel="noopener noreferrer"&gt;JsonAlias&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonaliasoptions.html" rel="noopener noreferrer"&gt;JsonAliasOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonAnyGetter
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;@JsonAnyGetter&lt;/code&gt; decorator allows the flexibility of using a Map or an Object Literal field as standard properties.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonanygetter" rel="noopener noreferrer"&gt;JsonAnyGetter&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonanygetteroptions.html" rel="noopener noreferrer"&gt;JsonAnyGetterOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonAnySetter
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonAnySetter&lt;/code&gt; allows us to define a logical "any setter" mutator using a non-static two-argument method to be used as a "fallback" handler for all otherwise unrecognized properties found from JSON content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonanysetter" rel="noopener noreferrer"&gt;JsonAnySetter&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/types.html#jsonanysetteroptions" rel="noopener noreferrer"&gt;JsonAnySetterOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonAppend
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonAppend&lt;/code&gt; can be used to add "virtual" properties to be written after regular properties.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonappend" rel="noopener noreferrer"&gt;JsonAppend&lt;/a&gt; - decorator options: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonappendoptions.html" rel="noopener noreferrer"&gt;JsonAppendOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonManagedReference and @JsonBackReference
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;@JsonManagedReference&lt;/code&gt; and &lt;code&gt;@JsonBackReference&lt;/code&gt; decorators can handle parent/child relationships and work around loops.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonmanagedreference" rel="noopener noreferrer"&gt;JsonManagedReference&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonmanagedreferenceoptions.html" rel="noopener noreferrer"&gt;JsonManagedReferenceOptions&lt;/a&gt;, &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonbackreference" rel="noopener noreferrer"&gt;JsonBackReference&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonbackreferenceoptions.html" rel="noopener noreferrer"&gt;JsonBackReferenceOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonClassType
&lt;/h2&gt;

&lt;p&gt;As said before, the &lt;code&gt;@JsonClassType&lt;/code&gt; is used to define the type of a class property or method parameter. A type is defined as an Array of JavaScript classes, such as &lt;code&gt;[Number]&lt;/code&gt; for properties of type number or &lt;code&gt;[Array, [Number]]&lt;/code&gt; for properties of type &lt;code&gt;Array&amp;lt;number&amp;gt;&lt;/code&gt; or &lt;code&gt;[Map, [String, Object]]&lt;/code&gt; for properties of type &lt;code&gt;Map&amp;lt;string, any&amp;gt;&lt;/code&gt;.&lt;br&gt;
Why an Array of JavaScript classes? Because in this way you can map complex types such as &lt;code&gt;Map&amp;lt;string, any&amp;gt;&lt;/code&gt; using &lt;code&gt;[Map, [String, Object]]&lt;/code&gt; or &lt;code&gt;Array&amp;lt;Set&amp;lt;any&amp;gt;&amp;gt;&lt;/code&gt; using &lt;code&gt;[Array, [Set, [Object]]]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonclasstype" rel="noopener noreferrer"&gt;JsonClassType&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonclasstypeoptions.html" rel="noopener noreferrer"&gt;JsonClassTypeOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonCreator
&lt;/h2&gt;

&lt;p&gt;We can use the &lt;code&gt;@JsonCreator&lt;/code&gt; decorator to define constructors and factory methods as one to use for instantiating new instances of the associated class.&lt;br&gt;
It’s very helpful when we need to deserialize some JSON that doesn’t exactly match the target entity we need to get, also with the help of the &lt;code&gt;@JsonProperty&lt;/code&gt; decorator.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsoncreator" rel="noopener noreferrer"&gt;JsonCreator&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsoncreatoroptions.html" rel="noopener noreferrer"&gt;JsonCreatorOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonSerialize and @JsonDeserialize
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonSerialize&lt;/code&gt; and &lt;code&gt;@JsonDeserialize&lt;/code&gt; are used to indicates the use of a custom serializer/deserializer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonserialize" rel="noopener noreferrer"&gt;JsonSerialize&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonserializeoptions.html" rel="noopener noreferrer"&gt;JsonSerializeOptions&lt;/a&gt;, &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsondeserialize" rel="noopener noreferrer"&gt;JsonDeserialize&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsondeserializeoptions.html" rel="noopener noreferrer"&gt;JsonDeserializeOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonFilter
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonFilter&lt;/code&gt; can be used to indicate which logical filter is to be used for filtering out properties of type (class) decorated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonfilter" rel="noopener noreferrer"&gt;JsonFilter&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonfilteroptions.html" rel="noopener noreferrer"&gt;JsonFilterOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonFormat
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonFormat&lt;/code&gt; is a general-purpose decorator used for configuring details of how values of properties are to be serialized.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonformat" rel="noopener noreferrer"&gt;JsonFormat&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/types.html#jsonformatoptions" rel="noopener noreferrer"&gt;JsonFormatOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonGetter and @JsonSetter
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonGetter&lt;/code&gt; and &lt;code&gt;@JsonSetter&lt;/code&gt; are alternatives to more general &lt;code&gt;@JsonProperty&lt;/code&gt; decorator to mark a method as a getter/setter method for a logical property.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsongetter" rel="noopener noreferrer"&gt;JsonGetter&lt;/a&gt; - decorator options: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsongetteroptions.html" rel="noopener noreferrer"&gt;JsonGetterOptions&lt;/a&gt;, &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonsetter" rel="noopener noreferrer"&gt;JsonSetter&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonsetteroptions.html" rel="noopener noreferrer"&gt;JsonSetterOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonIdentityInfo
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonIdentityInfo&lt;/code&gt; indicates that Object Identity should be used when serializing/deserializing values - for instance, to deal with infinite recursion type of problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonidentityinfo" rel="noopener noreferrer"&gt;JsonIdentityInfo&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonidentityinfooptions.html" rel="noopener noreferrer"&gt;JsonIdentityInfoOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonIdentityReference
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonIdentityReference&lt;/code&gt; can be used for customizing details of a reference to Objects for which "Object Identity" is enabled (see &lt;code&gt;@JsonIdentityInfo&lt;/code&gt;). The main use case is that of enforcing the use of Object Id even for the first time an Object is referenced, instead of the first instance being serialized as full Class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonidentityreference" rel="noopener noreferrer"&gt;JsonIdentityReference&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonidentityreferenceoptions.html" rel="noopener noreferrer"&gt;JsonIdentityReferenceOptions&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  @JsonIgnore, @JsonIgnoreProperties, and @JsonIgnoreType
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonIgnore&lt;/code&gt; is used to mark a property to be ignored at the field level during serialization and deserialization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonignore" rel="noopener noreferrer"&gt;JsonIgnore&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/types.html#jsonignoreoptions" rel="noopener noreferrer"&gt;JsonIgnoreOptions&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@JsonIgnoreProperties&lt;/code&gt; can be used as a class-level decorator that marks a property or a list of properties that will be ignored during serialization and deserialization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonignoreproperties" rel="noopener noreferrer"&gt;JsonIgnoreProperties&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonignorepropertiesoptions.html" rel="noopener noreferrer"&gt;JsonIgnorePropertiesOptions&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@JsonIgnoreType&lt;/code&gt; indicates that all properties of decorated type are to be ignored during serialization and deserialization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonignoretype" rel="noopener noreferrer"&gt;JsonIgnoreType&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/types.html#jsonignoretypeoptions" rel="noopener noreferrer"&gt;JsonIgnoreTypeOptions&lt;/a&gt;.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonInclude
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonInclude&lt;/code&gt; can be used to exclude properties with empty/null/default values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsoninclude" rel="noopener noreferrer"&gt;JsonInclude&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/types.html#jsonincludeoptions" rel="noopener noreferrer"&gt;JsonIncludeOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonInject
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonInject&lt;/code&gt; decorator is used to indicate that value of decorated property will be injected during deserialization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsoninject" rel="noopener noreferrer"&gt;JsonInject&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsoninjectoptions.html" rel="noopener noreferrer"&gt;JsonInjectOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonNaming
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonNaming&lt;/code&gt; decorator is used to choose the naming strategies (&lt;code&gt;SNAKE_CASE&lt;/code&gt;, &lt;code&gt;UPPER_CAMEL_CASE&lt;/code&gt;, &lt;code&gt;LOWER_CAMEL_CASE&lt;/code&gt;, &lt;code&gt;LOWER_CASE&lt;/code&gt;, &lt;code&gt;KEBAB_CASE&lt;/code&gt;, and &lt;code&gt;LOWER_DOT_CASE&lt;/code&gt;) for properties in serialization, overriding the default.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonnaming" rel="noopener noreferrer"&gt;JsonNaming&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonnamingoptions.html" rel="noopener noreferrer"&gt;JsonNamingOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonProperty
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonProperty&lt;/code&gt; can be used to define a non-static method as a "setter" or "getter" for a logical property or non-static object field to be used (serialized, deserialized) as a logical property.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonproperty" rel="noopener noreferrer"&gt;JsonProperty&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonpropertyoptions.html" rel="noopener noreferrer"&gt;JsonPropertyOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonPropertyOrder
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonPropertyOrder&lt;/code&gt; can be used to specify the order of properties on serialization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonpropertyorder" rel="noopener noreferrer"&gt;JsonPropertyOrder&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonpropertyorderoptions.html" rel="noopener noreferrer"&gt;JsonPropertyOrderOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonRawValue
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonRawValue&lt;/code&gt; decorator indicates that the decorated method or field should be serialized by including literal String value of the property as is, without quoting of characters. This can be useful for injecting values already serialized in JSON or passing javascript function definitions from server to a javascript client.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonrawvalue" rel="noopener noreferrer"&gt;JsonRawValue&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/types.html#jsonrawvalueoptions" rel="noopener noreferrer"&gt;JsonRawValueOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonRootName
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonRootName&lt;/code&gt; decorator is used - if wrapping is enabled - to specify the name of the root wrapper to be used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonrootname" rel="noopener noreferrer"&gt;JsonRootName&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonrootnameoptions.html" rel="noopener noreferrer"&gt;JsonRootNameOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Polymorphic Type Handling Decorators: @JsonTypeInfo, @JsonSubTypes, and @JsonTypeName
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@JsonTypeInfo&lt;/code&gt;: indicates details of what type information to include in serialization; &lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsontypeinfo" rel="noopener noreferrer"&gt;JsonTypeInfo&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsontypeinfooptions.html" rel="noopener noreferrer"&gt;JsonTypeInfoOptions&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@JsonSubTypes&lt;/code&gt;: indicates sub-types of the annotated type; &lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonsubtypes" rel="noopener noreferrer"&gt;JsonSubTypes&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonsubtypesoptions.html" rel="noopener noreferrer"&gt;JsonSubTypesOptions&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@JsonTypeName&lt;/code&gt;: defines a logical type name to use for annotated class; &lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsontypename" rel="noopener noreferrer"&gt;JsonTypeName&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsontypenameoptions.html" rel="noopener noreferrer"&gt;JsonTypeNameOptions&lt;/a&gt;.
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  @JsonTypeId
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonTypeId&lt;/code&gt; decorator is used to indicate that the annotated property should be serialized as the type id when including polymorphic type information, rather than as a regular property. That polymorphic metadata is used during deserialization to recreate objects of the same subtypes as they were before serialization, rather than of the declared supertypes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsontypeid" rel="noopener noreferrer"&gt;JsonTypeId&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/types.html#jsontypeidoptions" rel="noopener noreferrer"&gt;JsonTypeIdOptions&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  @JsonTypeIdResolver
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonTypeIdResolver&lt;/code&gt; decorator can be used to plug a custom type identifier handler to be used for converting between JavaScript types and type id included in JSON content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsontypeidresolver" rel="noopener noreferrer"&gt;JsonTypeIdResolver&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsontypeidresolveroptions.html" rel="noopener noreferrer"&gt;JsonTypeIdResolverOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonUnwrapped
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonUnwrapped&lt;/code&gt; defines values that should be unwrapped/flattened when serialized/deserialized.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonunwrapped" rel="noopener noreferrer"&gt;JsonUnwrapped&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonunwrappedoptions.html" rel="noopener noreferrer"&gt;JsonUnwrappedOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonValue
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonValue&lt;/code&gt; decorator indicates that the value of decorated accessor (either field or "getter" method) is to be used as the single value to serialize for the instance, instead of the usual method of collecting properties of value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonvalue" rel="noopener noreferrer"&gt;JsonValue&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/types.html#jsonvalueoptions" rel="noopener noreferrer"&gt;JsonValueOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  @JsonView
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;@JsonView&lt;/code&gt; decorator is used for indicating view(s) that the property that is defined by method or field decorated is part of. If multiple View class identifiers are included, the property will be part of all of them. It is also possible to use this decorator on classes to indicate the default view(s) for properties of the type, unless overridden by per-property decorator.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API&lt;/strong&gt;: &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/modules/decorators.html#jsonview" rel="noopener noreferrer"&gt;JsonView&lt;/a&gt; - decorator options &lt;a href="https://pichillilorenzo.github.io/jackson-js/latest/interfaces/types.jsonviewoptions.html" rel="noopener noreferrer"&gt;JsonViewOptions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In the next part ("&lt;a href="https://dev.to/pichillilorenzo/jackson-js-examples-for-client-angular-and-server-node-js-side-part-2-128n"&gt;Jackson-js: Examples for client (Angular) and server (Node.js) side (Part 2)&lt;/a&gt;"), I will give a simple example using &lt;a href="https://github.com/pichillilorenzo/jackson-js" rel="noopener noreferrer"&gt;&lt;code&gt;jackson-js&lt;/code&gt;&lt;/a&gt; with Angular 9 for the client side and two examples for the server side: one using Node.js + &lt;a href="http://expressjs.com/" rel="noopener noreferrer"&gt;Express&lt;/a&gt; + SQLite3 (with &lt;a href="https://sequelize.org/" rel="noopener noreferrer"&gt;Sequelize 5&lt;/a&gt;) and another one using Node.js + &lt;a href="https://github.com/strongloop/loopback-next" rel="noopener noreferrer"&gt;LoopBack 4&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>decorators</category>
      <category>javascript</category>
      <category>jsonparse</category>
      <category>jsonstringify</category>
    </item>
  </channel>
</rss>
