Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

convert json to json string ios swift

func jsonToString(json: AnyObject){
        do {
          let data1 =  try NSJSONSerialization.dataWithJSONObject(json, options: NSJSONWritingOptions.PrettyPrinted) // first of all convert json to the data
            let convertedString = String(data: data1, encoding: NSUTF8StringEncoding) // the data will be converted to the string
            print(convertedString) // <-- here is ur string  

        } catch let myJSONError {
            print(myJSONError)
        }

    }
Comment

swift encode json

// for encoing your model or sturct must inherit codable protocol
var general = [str: products]
let encodedData = try? JSONEncoder().encode(general)
Comment

convert json to json string ios swift

func jsonToString(json: AnyObject){
        do {
          let data1 =  try NSJSONSerialization.dataWithJSONObject(json, options: NSJSONWritingOptions.PrettyPrinted) // first of all convert json to the data
            let convertedString = String(data: data1, encoding: NSUTF8StringEncoding) // the data will be converted to the string
            print(convertedString) // <-- here is ur string  

        } catch let myJSONError {
            print(myJSONError)
        }

    }
Comment

PREVIOUS NEXT
Code Example
Javascript :: Error: Node Sass version 5.0.0 is incompatible with ^4.0.0 
Javascript :: get index of first number in string javascript 
Javascript :: Ping discord 
Javascript :: how to input from user in javascript 
Javascript :: javascript trim text 
Javascript :: generate qr code react 
Javascript :: passing multiple props to child component in react 
Javascript :: JavaScript Initialize Variables 
Javascript :: js objects 
Javascript :: scroll btn 
Javascript :: npm jsonwebtoken 
Javascript :: threejs perspectivecamera 
Javascript :: afficher une variable dans la console javascript 
Javascript :: d3 script 
Javascript :: angular map 
Javascript :: how to add an event listener to a function javascript 
Javascript :: javascript pop object from array 
Javascript :: sequelize get data 
Javascript :: js add timestamp clg 
Javascript :: javascript foreach loop array 
Javascript :: sequelize findall 
Javascript :: Run Express in Production Mode 
Javascript :: TypeError: path must be absolute or specify root to res.sendFile 
Javascript :: Convert mnemonic to seed in javascript 
Javascript :: gojs update text 
Javascript :: jquery select input value empty and hasclass 
Javascript :: if browser reactjs 
Javascript :: auto increase hight of textarea with alpine js 
Javascript :: while loops js 
Javascript :: nodejs add to array 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =