Questions tagged [json]

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

75 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
11
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, ...
3
votes
0answers
33 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 ...
3
votes
1answer
390 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 ...
3
votes
1answer
448 views

How to pass a json data from Observer to phtml

Upon Login, I am sending an API call(post request) to an external site in observer which return a JSON response. I need to populate a table in the phtml with the response received. Hence I am trying ...
2
votes
0answers
236 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 ...
2
votes
0answers
111 views

Magento 2: Is there a way to return custom json response from REST API without building a data interface?

I have a few custom REST API interfaces on my module & they all need to return a standard json response (different on each). After a little research, I realized that I can't do something like @...
2
votes
0answers
248 views

How to find Magento version using API (JSON specifically)

Using the JSON RestAPI, I need to do things slightly differently depending on the version of Magento due to as-yet un-fixed bugs (specifically https://github.com/magento/magento2/issues/18005). I can ...
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(...
2
votes
2answers
500 views

how i get the json body in controller in magento 2?

<?php namespace VEndor\Module\Controller\Index; class Index extends \Magento\Framework\App\Action\Action { protected $resultPageFactory; public function __construct( \Magento\...
2
votes
1answer
588 views

Why doesn't Magento setHeader('application/json') when appropriate in OnePageCheckout?

I have a Magento environment that is tunneled through Apache via mod_proxy. During the one-page checkout process, Apache is erroneously wrapping JSON responses in HTML because the response header says ...
2
votes
0answers
124 views

curl and json approve conversion Rest API

i'm currently coding a little api for extole approve conversion api. It's only suppose to send data on declined orders which is equal to cancelled in the magento admin. Here is what i have written ...
1
vote
0answers
31 views

Magento 2.2(checkout page): Uncaught SyntaxError: Unexpected end of JSON input

I have read other posts here in this forum but I am having a hard time finding the solution to my problem. On the checkout page, the shipping method does not show and is only loading forever. (we are ...
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/...
1
vote
0answers
77 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
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
0answers
303 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/...
1
vote
1answer
94 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
0answers
26 views

How to retrieve the JSON string inside a controller and convert it in an array?

I have a controller that returns a JSON on the page. This is the code //Above in the code injection of \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory $result=[ "orderId" ...
1
vote
1answer
435 views

Magento 2 jsonParse() does not receive data, Unexpected token '

I'm creating a js template in Magento 2. When I call js, I get an Uncaught SyntaxError: Unexpected token 'in JSON at position 96. Why jsonParse () does not get the value? Can somebody help me? file ....
1
vote
0answers
250 views

How to add a new attribute in order response json in get order api

I have added a new column "old_order_id" in sales_order table using upgradeSchema. Now, I need to set that "old_order_id" through API. So, how to add that attribute(old_order_id) in request json ...
1
vote
0answers
38 views

Product images in multiple stores using JSON API

I have four stores created, and I'm trying to upload a single image for the same product in each of the stores. My issue is that to get an image to show in the category front end view, I need to ...
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: ...
1
vote
1answer
268 views

How to append a new Json element to setData with resultJsonFactory in Magento2

public function __construct( JsonFactory $resultJsonFactory ) { $this->resultJsonFactory = $resultJsonFactory; } $response = $this->resultJsonFactory->create(); $response->...
1
vote
2answers
101 views

Jquery post request returning html

I am trying to make an AJAX request in my Magento 2.1.8 custom module. The Http Post Request is returning all of the data i expect it to in JSON format, However it is also adding on some of my html ...
1
vote
0answers
59 views

Content Blocks Backend not loading

I'm not sure what caused this but out of nowhere my blocks in the backend of my Magento is not loading it sits there with a loading icon. https://imgur.com/a/9Osu2 I am also getting this error with ...
1
vote
1answer
682 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 ...
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 ...
1
vote
1answer
483 views

How to handle custom_attributes from REST API data?

When dealing with the Magento v2 API, I faced a problem where getting product details have inconsistent data from REST API. Example 1: Example 2: These are Note 8 and iPhone 8 data and we can see ...
1
vote
0answers
76 views

How to get every product's quantity in event observer json file?

public function productDataToJson(Varien_Event_Observer $observer) { $category = Mage::getModel('catalog/category'); $tree = $category->getTreeModel(); $tree->load(); $ids = $tree->...
1
vote
1answer
69 views

Magento add to cart product issue

Getting really weird issue. Some of my products are not getting to cart. https://www.saree.com/beige-and-navy-blue-art-silk-blouse-with-stone-work-saaabl003 while this one works https://www.saree....
1
vote
0answers
693 views

500 Internal Server Error during onepage checkout saveShippingMethod

Hi I have problem in my onepage checkout. I can't choose pay method because ajax all time is reload. In console I have 500 (Internal Server Error) (in adress onepage/json/saveShippingMethod. I can't ...
1
vote
0answers
119 views

Magento 2: How to get JSON API Variable in Model

Below is the REST API called on Checkout Page, when you have multiple address & u click on "Ship here" magento/rest/default/V1/carts/mine/estimate-shipping-methods-by-address-id It passes ...
1
vote
0answers
440 views

Magento 2 calculate custom text fields length and width on product view page

How is possible in magento 2.0? I successfully active in magento 1.9 for bellow thing. I am trying to create a product with two custom text fields: Length and Width. When the user types, both a length ...
1
vote
0answers
87 views

How to return global_messages as JSON string?

I am trying to echo global_messages via JSON on the frontend. I have been looking around for some examples of how to return global_messages as a JSON string but cannot find anything that has helped ...
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
18 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)...
0
votes
0answers
23 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>...
0
votes
0answers
19 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
18 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
0answers
26 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
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/...
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 ...
0
votes
0answers
26 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
262 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 ...
0
votes
0answers
38 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
42 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
0
votes
1answer
81 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....