We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [json]

This tag should be used for questions related to json data types

Filter by
Sorted by
Tagged with
0
votes
0answers
7 views

Uncaught Syntax Error: Unexpected number in JSON at position 2. Why in Magento2?

["092019,082019,072019,062019,052019,042019,032019,022019,012019"] Uncaught SyntaxError: Unexpected number in JSON at position 2 at JSON.parse (<anonymous>) at Object.success (admin.php:667)...
10
votes
1answer
1k views

Magento2 : API Stock update

Using Magento 2.2.2, I was trying to add stock updates to a pre-existing setup using the official defined endpoint: rest/V1/products/testsku/stockItems/1 with { "stock_item": { "qty": 1234, ...
0
votes
0answers
20 views

Facing issue while sending a single element XML payload in array type

So I am sending below-mentioned XML payload to Magento's API: https://magento2.jitterbit.com/rest/all/V1/products/{sku}/links XML Payload: <items> <link_type>related</link_type>...
1
vote
2answers
1k views

How to create json file in magento 2

I need to create a json file with data and store that file in specific directory of magento 2. Can any one please tell me how we can achieve this in magento2 in standard way like file system. Please ...
0
votes
0answers
17 views

Magento 2 JSON.parse: unexpected non-whitespace | and <pre> tag in json after json response in every APIs

show JSON.parse: unexpected non-whitespace | and tag in json after json response in every APIs; And tag is appending after tag in all front end and admin pages and also in ajax response ][send ...
0
votes
0answers
17 views

problem with getJsonSwatchConfig class in magento 2.3

I'm using the getJsonSwatchConfig class (\Magento\Swatches\Block\Product\Renderer\Listing\Configurable) everything works fine, but in JSON it never brings me the images
0
votes
0answers
10 views

Extension attributes in order api with generic object without creating new interface

I want to add some data to order api using extension attributes. I know I can create an interface for the object I will use. But the object has variable depth. And the key names also varies. For ...
0
votes
1answer
40 views

Magento 2 Get product options id for sql query

I have this query: SELECT * FROM `sales_order_item` WHERE `product_options` LIKE '%2010%' With the last bit being the decoded option id, I need to find two specific option ids to use inside this ...
0
votes
1answer
2k views

Magento .htaccess Response for preflight has invalid HTTP status code 400

I am doing a rest call from Magento to Angular 2. I am facing this CORS issue and trying many workarounds but nothing seems to work. Figured out its server side issue and made the below changes in ...
0
votes
0answers
23 views

Which is best option encode json in magento 2 for now

Should I continue to use json_encode? Or use serialize class of Magento \Zend_Json::encode this may be old, I don't think we should use this in higher Magento version json_encode(something) ...
0
votes
2answers
137 views

Magento 2 WebAPI json encode

I'm returning JSON via an endpoint in Magento 2 this bit of JSON looks like the following: $new_json = [ 'component_1' => '[{....}]', 'component_2' => '[{...}]' ]; ...
2
votes
1answer
1k views

Magento 2.2.2, Unable to unserialize value, magento_umask and edting Json.php did not help

After upgrade I'm getting below error in my local : Exception #0 (InvalidArgumentException): Unable to unserialize value. #0 myPath/vendor/magento/module-theme/Controller/Result/MessagePlugin.php(...
1
vote
3answers
2k views

magento 2 custom api return in json without response tag

I have created a custom api following "inchoo" tutorial. But I am getting the data in string format instead of json. From my browser I am getting a tag surrounding the api return as below. But ...
0
votes
0answers
17 views

How to fetch and print quantities of multiple barcodes i have in system api?

I am using magento2.2 version. I have an API of products coming from another system, for a specific purpose i want to print specific quantity from API. Here is the sample JSON data of API coming ...
0
votes
0answers
15 views

How to save file in directory using ajax post with php in magento 2

I have a Js code in my phtml like below. var data = new FormData(); data.append("data" , "the_text_you_want_to_save"); var xhr = new XMLHttpRequest(); xhr.open( 'post', 'http://mysite/...
1
vote
1answer
663 views

Upgrade Magento 2 via composer not working

I try to upgrade Magento 2.1.6 to Magento 2.1.9. To do this I ran this command: composer require magento/product-community-edition 2.1.9 --no-update after this I ran : composer update and I ...
0
votes
2answers
18 views

Magento1.8 - Restapi Custom Module - Return variable formatting issue

This is my first post so please let me know if I missed sharing any detail on my problem. I have below files ready in Magento kept in app/code/community: A. Autogen > Restapi > etc > api2.xml B. ...
0
votes
0answers
10 views

How to get the price of this JSON products to be exibihited on my html in a dropdown list?

I have this JSON table that I need to add on my HTML as a dropdown list and when the chosen product is selected, it shows its price and shows a button to simulate a shopping procedure (increase items ...
1
vote
1answer
29 views

Custom API POST JSON

I created a custom API REST : https://domain/rest/V1/action This is a POST request, with JSON in the body. Example : { "my_test_here": [ { "first_field": "value1", "...
0
votes
0answers
387 views

Product detail page image not loading on front end

Product detail page images are not loading. The pointer is just spinning. I have read lots of threads. Clear cache, reindexed, change permissions. Finally, I got a problem. but unable to fix it. :-/ ...
0
votes
0answers
23 views

Will Magento generated MicroData interfere with JSON-ld structured data in Magento 1.9?

I see that Magento 1.9 generates MicroData for it products. Before I realized this I started using JSON-LD to build out some of those same objects. My questions are one; Will Google penalize me ...
0
votes
1answer
35 views

Magento 2 Check if a Variable contains JSON encoded code or not?

I have a variable $image, Sometimes it containes JSON Encoded value and sometimes it is not. What I need? If $image doesn't have JSON encoded data, I want to do my custom code. I am trying this: ...
2
votes
1answer
72 views

Get current Logged user Wishlist products id in Ajax Call Magento 2.3

I Want currently logged user all wishlist products id's json array via ajax call ?
0
votes
1answer
184 views

Magento 2.3 REST API Json response format issue

How I can change the json format from [ [ { "success": [ { "code": 200, "response": { "...
0
votes
1answer
167 views

json encode in magento 2

I just wanted to know that what is the right way to print array data into json format. I Know we can use php function json_encode() but is this the right way to print array data? Because i saw one of ...
2
votes
3answers
7k views

Magento2: How to convert JSON to Array of nested objects

I am wanting to understand if there are some functions in Magento Framework which will assist me in mapping an array of nested objects from JSON (such as what would happen when the REST API is ...
3
votes
0answers
31 views

Magento 1.9 - How to get JSON config by a bundle item id in cart?

When I have a bundle product in the cart, I can edit it by clicking the edit button . At this point, a page with the product to edit will be loaded. Also, a function named "getJSONConfig()" will be ...
2
votes
2answers
71 views

Magento1.9.4: Images Not Uploading in Admin – JSON in Syntax Error

I am trying to upload an image - something which I have done a hundred times. Now it gets stuck with "uploading..." showing. I have tried disabling extensions. I haven't made any changes. There have ...
1
vote
0answers
25 views

Magento Json Serializer vs native PHP

Is there any special reason why I should use the Magento framework classes such as JSON Serializer vs just native PHP? https://github.com/magento/magento2/blob/2.3/lib/internal/Magento/Framework/...
0
votes
0answers
34 views

Magento2 pass json data format in call to external service

Currently I'm referencing this article to post data to external services in a form data format. Some of the external services require in json format. How should I do it if I want to pass json format ...
0
votes
0answers
34 views

Magento 2.5: Uncaught SyntaxError: Unexpected end of JSON input in checkout page

I have an error in my checkout page of Magento 2.2.5 image loader loading continuously in checkout page.Show error in console of google chrome
5
votes
3answers
22k views

Magento2 - How to get JSON response from Controller [closed]

I've created my custom controller and I want to return the result formated with JSON. I always get a JSON parse error "JSON.parse: unexpected character at line 1 column 1 of the JSON data" and the ...
0
votes
1answer
75 views

Unable to unserialize value

I have a problem in my Magento 2.2.5 shop. I did the migration from magento 1.9.2.1 When I want to change the category from a product I get the next error: Unable to unserialize value. The exception....
1
vote
0answers
70 views

Unable to serialize value. at /public_html/vendor/magento/framework/Serialize/Serializer/Json.php:26)"} []

main.CRITICAL: Unable to serialize value. {"exception":"[object] (InvalidArgumentException(code: 0): Unable to serialize value. at /public_html/vendor/magento/framework/Serialize/Serializer/Json....
1
vote
1answer
70 views

How to use resultJsonFactory in Model file magento2

I have used below code to print response from my Model file. <?php class CountrylistManagement implements \Vendor\Module\Api\CountrylistManagementInterface { protected $_storeManager; ...
0
votes
1answer
27 views

Multiple For each loop value to Json string

$data= array(); foreach($itfdatas as $key=>$itfdata){ $checkemps = explode(',',$itfdata['employee_id']); $data[] = array( 'id'=>mysql_real_escape_string($itfdata['P_id']), ...
6
votes
2answers
1k views

Magento 2.3 use of `db_schema_whitelist.json` file in etc directory of each module

What is the use of db_schema_whitelist.json located in Magento Catalog etc directory? In Magento 2.3 version, I found db_schema_whitelist.json and db_schema.xml files, in the Magento_Catalog module. ...
2
votes
0answers
211 views

Magento 2.3.1 JSON.parse: unterminated string at line 2 column 1009

I am unable to set payment method in Magento 2.3.1. As soon as I click on the payment method button all JavaScript functions are killed. open error log nothing to show, but browser console point me ...
0
votes
0answers
27 views

I can not unserialize this string

I have saved this string into the database. when I trying to decode this string by below sentence this does not working. \Magento\Framework\Serialize\Serializer\Json $serializer $this->...
2
votes
2answers
125 views

How to overwrite .php file of lib directory?

Any one tell me how i can overwrite this file in magento 2.3 Path: Magento2\lib\internal\Magento\Framework\Webapi\Rest\Response\Renderer\Json.php
1
vote
0answers
19 views

How to display a popup on the product page at the touch of a button, add to the basket? Magento 2

There is an event that checks if the goods in the basket when we go to the product page. If there is an attribute in the goods that allows to deliver the goods on the day of the order, if this ...
1
vote
1answer
60 views

Create order data json file in root after checkout is completed

I want a json file of order data to be created in root directory after the checkout is completed. I have been searching this for hours now but still luck.
1
vote
0answers
260 views

Ajax call always returns in error from controller Magento 2

From my controller, I return a JSON data to my Ajax call but it always goes in the error section, even when it's not an error. jQuery.ajax({ type: 'POST', url: '/yxcustomer/index/...
0
votes
1answer
3k views

Convert model collection to json_encode

Currently I'm converting my collection data to json_encode like this: $collections = $this->modelFactory->create()->getCollection() ->addFieldToFilter('status','1'); $...
3
votes
1answer
69 views

How to avoid using php://input?

I have a POST endpoint that receives a JSON payload. I'm using the Magento\Framework\App\Request\Http class to try and retrieve my POST data. If I run $data = $this->request->getPost();, ...
3
votes
1answer
338 views

Magento 2 Unexpected number in JSON at position 1

Am working on magento 2.3 and have an error in console product page,i have no idea what is it,i guess its fetching json data with error in product gallery part. I tried every thing like clearing ...
1
vote
1answer
75 views

Magento 2.3 - Get child categories of parent

In Magento 2.2 I've written this little script. /** * Index constructor. * * @param Context $context * @param StoreManagerInterface $storeManager * @param ...
1
vote
2answers
669 views

Magento 2 ajax success json error

I'm trying to to an ajax call using following code $.ajax({ type: 'POST' ,url: SOME_URL ,data: {testdata : testid} ,...
0
votes
1answer
35 views

Get product info in JSON/XML without authentication

Is it possible to get product info in JSON/XML format without using any authentication from a website using Magento. For example, Shopify provides product's info as https://mystore/products/product-...
1
vote
0answers
1k views

Magento2: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

The above code written in catalog_product_view.xml in module-catalog. For this block, customer info in header after login not loading. In console I'm getting this error: SyntaxError: JSON.parse: ...