Questions tagged [jsonencoder]

Use this tag for `JSONEncoder` questions on Apple platforms.

JSONEncoder is a class, introduced in Swift 4, for encoding types on Apple operating systems that conform to Encodable protocol (or Codable protocol, which is type alias for Encodable & Decodable). This offers a simple mechanism to easily generate JSON from Encodable Swift types. This applies to standard Swift collections, such as Array and Dictionary, but custom types can conform to Encodable to participate in this simplified JSON encoding process.

This replaces/supplements the JSONSerialiation class used in prior Swift versions.

See also:

125 questions
0
votes
2 answers

JSONEncoder with multiple structures

Hi I have multiple JSON Packets like I wrote below. { "data" : { "lng" : 36.159999999999997, "lat" : 50.359999999999999, "accuracy" : 5 }, "header" : { "type" : "loc" } } and this one { "data" : { "time" :…
Stremovskyy
  • 452
  • 7
  • 18
-1
votes
3 answers

Unable to get the key value while json parsing in swift

I am using below code to parse json from API struct ResourceInfo: Decodable { let id: String let type: String // let department: String. -> Unable to get the value for department } struct CustomerInfo: Decodable { let name: String …
iOSAppDev
  • 2,755
  • 4
  • 39
  • 77
-1
votes
1 answer

how to open json file using python

JSONDecodeError: Expecting ':' delimiter: line 1 column 8388729 (char 8388728) import json with open('tweets.json') as jfile: d = json.load(jfile) i tried using this code.but it did not work. this is the sample data enter image description here
-1
votes
1 answer

Swift: encode [String:Any] to JSON

I have to encode a [String:Any] object to a JSON like this: { "timestamp": "2021-06-17T09:18:30.212Z", "readings": [ { "uuid": "string", "major": 0, "minor": 0, "macAddress": "string", "rssi": 0 } ] } I…
Luciano
  • 1,208
  • 2
  • 17
  • 36
-1
votes
1 answer

How to json encode Specific Key value using PHP?

I have tried this code but receiving error. $queryfetch = 'select * from table'; $result = mysqli_query($connection, $queryfetch); $row = mysqli_fetch_assoc($result); $data = []; foreach($row as $key) { $data[] = [ …
-1
votes
2 answers

Flutter Post Request with Nested JSON as Data + BLoC pattern

I have tried to pass JSON in Post Request using BLoC Pattern. jsonEncode({ 'MobileNo': _emailController.value, 'Password': _passwordController.value, 'IPAddress': '192.168.0.1', 'Latitude' : '23.04503', 'Longitude':…
Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
-1
votes
2 answers

Array to string conversion while using canvas js in yii2

I am trying to load a chart on my index page in yii2 project. Below is my code "2010", "y"=> 36.12), array("label"=> "2011", "y"=> 34.87), array("label"=> "2012", "y"=> 40.30), array("label"=> "2013",…
Moeez
  • 494
  • 9
  • 55
  • 147
-1
votes
2 answers

How to build a multidimensional json array with PHP while statement?

As you can see in the code below, there are two appointments on the 2020-01-13 but they get generated as a separate array. How can I put them both on the same array since they are on the same day? I'm fetching all the information from a database…
Grogu
  • 2,097
  • 15
  • 36
-1
votes
1 answer

Swift: Generic parameter 'T' could not be inferred

I have a git repository of an app that has been working properly and is available on iTunes. I recently wanted to add some updates to it and imported the project into xCode 10. When I tried to build the solution, I get an error "Generic parameter…
Artur L
  • 37
  • 7
-1
votes
2 answers

How do I convert my class object into JSON for Alamofire

EDIT: 19.02.2019 I tried the solutions offered. I went for a simpler option of passing a dictionary as the parameter and using Alamofire's JSONEncoder to turn it into a JSON object. This was the first thing I had tried but the problem was that…
-1
votes
1 answer

How to determine encoding format of string and then decode it

I have captured request content of a mobile app (iphone) through a proxy (Charles Proxy), but the content seems to be encoded which I want to decode into human-readable format. As the source of the encoding format is not known, I cannot decode it, I…
user1614862
  • 3,701
  • 7
  • 29
  • 46
-1
votes
1 answer

php api jsonencoding result make intiger key to string [0]=>val output "0" : val

$data['frame']["CollageDecoration"]["ClgD".$this->actionApiNumToWord($i+1)]["is_decoration"]="true"; …
-1
votes
2 answers

Unexpected token { in JSON

hello i am working with Elastic Search and Golang and after fetching data from elastic search index in Golang when i send the data to jquery using Json Encoder function of Golang i get "Unexpected token { in JSON " error while parsing the data in…
-2
votes
1 answer

In Swift, use a global CodingKeys (enum or struct) keeping my objects as simple as possible

In a simplified example, I have these JSONs Strings let jsonStringBird = """ { "identifier": "0001ABX", "name": "Doroty", "species_name": "Gorrion", } """ let jsonStringPlane = """ { "identifier": "PL1803", "name": "Boing…
Gerardo
  • 168
  • 2
  • 8
-2
votes
1 answer

python package for traversing data structures

I spent hours trying to figure out how to subclass and modify json.JSONEncoder to override how it encodes enum.Enum instances before learning that it literally wasn't possible, and that the only solution is to traverse my data structure and convert…
odigity
  • 7,568
  • 4
  • 37
  • 51
1 2 3
8
9