JSON Articles

Page 16 of 16

How to convert HASHMAP to JSON using GSON in Android?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 1K+ Views

GSON is java library, It is used to convert OBJECT to JSON and JSON to Object. Internally it going to work based on serialization and deserialization.This example demonstrates how to convert HASHAMP to JSON using GSON library.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code in build.gradle.apply plugin: 'com.android.application' android {    compileSdkVersion 28    defaultConfig {       applicationId "com.example.andy.myapplication"       minSdkVersion 15       targetSdkVersion 28       versionCode ...

Read More

Escaping/encoding single quotes in JSON encoded HTML5 data attributes

George John
George John
Updated on 30-Jul-2019 4K+ Views

To escape single quotes, use json_encode() to echo arrays in HTML5 data attributes.printf('', htmlspecialchars(json_encode(array('html5', ...)), ENT_QUOTES, 'UTF-8'));Or you can also using built-injson_encode(array('html5', ...), JSON_HEX_APOS)

Read More
Showing 151–152 of 152 articles
« Prev 1 12 13 14 15 16 Next »
Advertisements