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
1 answer

How to prevent negative stock value after using after insert trigger

I have a problem here I input the number of items purchased more than the stock I have, so the output is data minus example "-1" . I have the source json php below can you help me to improve my program so that I will be notified "items purchased are…
0
votes
1 answer

Convert Encoded String To JSON Array in Swift

I have an Encoded String: ("[{"carMake":"Mercedes","phone":"03001234567","insurancePolicyNo":"0123456","email":"a@g.com","full_name":"Steven Fin","registrationNo":"02134","insuranceProvider":"Michael","carModel":"Benz"},…
Taimoor Arif
  • 750
  • 3
  • 19
0
votes
1 answer

Swift: Non destructive JSON Encoder

I store user changeable settings as JSON in the keychain. The app has premium content that is only allowed if the user is subscribed. Depending on the subscription state, the JSONEncoder/Decoder skips some variable and sets it to a default value.…
Martin Claesson
  • 487
  • 6
  • 16
0
votes
1 answer

php expects parameter 2 json_encode error

I have this array that returns a parameter error. Why? echo json_encode( array("replies" => array( array("message" => "Success ✅") )), array("variables" => array( array("data1" => "data2") )) …
Club
  • 111
  • 1
  • 8
0
votes
1 answer

Error "JSON parse unexpected non-whitespace character " in php

I have a big DB data to display. If i do this with just PHP/SQL, it result too big and it take too long for showing data. So i prefere to display all data with AJAX. But, when i create the PHP page for encode the data to JSON, and then add the…
s.elettro
  • 55
  • 1
  • 8
0
votes
1 answer

Terraform issue creating the resource "azurerm_synapse_linked_service" specifically with the "type_properties_json" field

I am trying to create a Synapse Workspace Linked Service using Terraform and am running into a constant snag with the "type_properties_json" field that is (required). When I try to establish a Linked Service to an SFTP resource type, I can do so…
aseb
  • 274
  • 2
  • 11
0
votes
1 answer

How can we prevent adding special characters when we json_encode an array in php?

The main array is: array (size=2) 0 => array (size=2) 'message' => string 'Dear subscriber, We are working to resolve your link down issue. It will take approximately 2-4 hours to fix the issue.We appreciate your cordial support and…
Mishu Das
  • 19
  • 3
0
votes
2 answers

"jsonencode" expects only 1 argument(s)

I am trying to terraform an AWS role. I followed this example where they had only attached one json policy: resource "aws_iam_policy" "policy" { name = "test_policy" path = "/" description = "My test policy" # Terraform's…
x89
  • 2,798
  • 5
  • 46
  • 110
0
votes
2 answers

Flutter HTTP post request JSON handling not working properly

I am using nodejs backend with flutter app. I use flutter http package to send requests. I want to send datetime via the request, so I converted it to string. So in the node backend this data cannot be converted into original types (like DateTime or…
Pasan Madhushan
  • 205
  • 1
  • 4
  • 10
0
votes
0 answers

Swift JSONEncoding problem with encoding a list of dictionaries

I am having problems with sending a list of dictionaries as the value for one of my keys in a dictionary. I'm sending a dictionary that represents a game, with one of the key value pairs being a list of points. So for my 'points' key the…
Adam Berard
  • 45
  • 1
  • 7
0
votes
1 answer

I couldn't convert a str to json in python

I am getting error Traceback (most recent call last): json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) My code: ``` HOST = '0.0.0.0' PORT = 10001 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind((HOST,…
Fabian
  • 11
  • 3
0
votes
2 answers

Json output array to php variable

prob an easy fix, but I'm stuck. So print_r($data) = stdClass Object ( [code] => 200000 [data] => stdClass Object ( [accountEquity] => 111 [unrealisedPNL] => 111 [marginBalance] => 111 [positionMargin] => 111 …
Mike
  • 1
0
votes
1 answer

Can I cancel a JSONEncoder Swift?

I have a JSONEncoder encoding a 20mb file, which takes ages to process. If the data it's processing changes, I'd like to cancel the encoding, and restart the encoding process but I can't think of a way to do this. Any ideas? I could call…
user139816
  • 214
  • 2
  • 14
0
votes
0 answers

how to use array with subarrays and json_encode to load part of the data

I have the below data in array with two sub-arrays 0 and 1. I am trying to load only sub-array data 0 or 1 every time via json_encode: My php code in my website:
FotisK
  • 1,055
  • 2
  • 13
  • 28
0
votes
1 answer

Encoding an array of generic structs

I am trying to make an API call that takes a JSON request body like so: [ { "op": "replace", "path": "/info/name", "value": "TestName" }, { "op": "replace", "path": "/info/number", "value": 100 }, { "op": "replace", "path": "/info/location",…
rgajrawala
  • 2,148
  • 1
  • 22
  • 35
1 2 3
8 9