Snippets tagged “json”
88 snippets use this tag.
- Can not deserialize instance of java.util.ArrayList out of START_OBJECT tokenJava
This error is usually encountered when trying to parse a JSON string that does not start with a JSON array, but rather a JSON object.
- Convert a JSON String to a HashMapJava
Here is an example of how you can convert a JSON string to a HashMap in Java:
- Convert a String representation of a Dictionary to a dictionaryPython
You can use the json module in Python to convert a string representation of a dictionary to a dictionary.
- Convert flat array to a delimited string to be saved in the databasePHP
You can use the implode() function to convert an array to a delimited string in PHP.
- Convert JSON to MapJava
You can use the Gson library to convert a JSON string to a Map in Java.
- Convert JsonObject to StringJava
To convert a JsonObject to a String in Java, you can use the JsonObject.toString method.
- Convert Python dict into a dataframePython
You can use the Pandas library to convert a Python dictionary into a dataframe.
- Converting JSON data to Java objectJava
To convert JSON data to a Java object, you can use the fromJson method of the Gson class.
- Curl and PHP - how can I pass a json through curl by PUT,POST,GETPHP
To pass a JSON object through cURL using the PUT method, you can use the following command:
- curl POST format for CURLOPT_POSTFIELDSPHP
To make a POST request with PHP's cURL functions, you can use the CURLOPT_POST option to send POST data.
- Date format Mapping to JSON JacksonJava
You can use the @JsonFormat annotation to specify the format of date fields in a JSON payload when serializing or deserializing using Jackson.
- Get a JSON object from a HTTP responseJava
To get a JSON object from a HTTP response in Java, you can use the JSONObject class from the org.json library.
- Get file content from URL?PHP
To get the contents of a file from a URL in PHP, you can use the file_get_contents function.
- Get latitude and longitude automatically using php, APIPHP
To get latitude and longitude automatically using PHP, you can use an API (Application Programming Interface) such as Google Maps API, OpenCage Geocoding API, or GeoCode.io API.
- Get list of JSON objects with Spring RestTemplateJava
To get a list of JSON objects using the Spring RestTemplate, you can use the exchange() method to send an HTTP GET request to the server, and then use the getBody() method of the ResponseEntity object to retrieve the list of objects.
- Get the data received in a Flask requestPython
In a Flask application, you can access the data received in a request using the request object.
- GSON throwing "Expected BEGIN_OBJECT but was BEGIN_ARRAY"?Java
If GSON is throwing a JsonSyntaxException with the message "Expected BEGIN_OBJECT but was BEGIN_ARRAY", it means that you are trying to parse a JSON array as if it were a JSON object.
- Guzzle 6: no more json() method for responsesPHP
In Guzzle 6, the json() method for parsing JSON responses has been removed.
- How can I force PHP to use strings for array keys?PHP
In PHP, array keys are typically automatically cast to integers if they are numeric, and to strings if they are not.
- How can I represent an 'Enum' in Python?Python
In Python, you can represent an Enum (enumeration) by using the enum module or by creating a class that inherits from enum.Enum.
- How do I get a YouTube video thumbnail from the YouTube API?PHP
To get a thumbnail image for a YouTube video in PHP, you can use the file_get_contentsfunction to make a GET request to the videos.list method of the YouTube Data API.
- How do I return a proper success/error message for JQuery .ajax() using PHP?PHP
To return a proper success/error message for jQuery.ajax() using PHP, you can do the following:
- How do I write JSON data to a file?Python
To write JSON data to a file in Python, you can use the json module.
- How do you return a JSON object from a Java ServletJava
To return a JSON object from a Java Servlet, you can use the following steps:
- How should I escape strings in JSON?Java
In JSON, certain characters must be escaped in strings.
- How to Compare Two JavaScrpt ArraysJavaScript
You can either loop through the arrays or convert them to string and then compare. This tutorial provides several fast methods of comparing two arrays.
- How to Convert a PHP Array to a JavaScript ArrayPHP
In this tutorial, you can find a comprehensive guideline on how to convert a PHP array to JavaScript accurately. Just check out the options and examples.
- How to Convert a PHP Object to an Associative ArrayPHP
If you want to get a proper explanation of how to convert a PHP object to an associative array, you are in the right place. Just follow the examples.
- How to convert a string to JSON object in PHPPHP
You can use the json_decode function in PHP to convert a JSON string into a PHP object.
- How to convert hashmap to JSON object in JavaJava
To convert a hashmap to a JSON object in Java, you can use the org.json library. Here's an example:
- How to convert jsonString to JSONObject in JavaJava
To convert a JSON string to a JSONObject in Java, you can use the JSONObject constructor that takes a String as an argument, like this:
- How to Convert MySQL Data to JSON with PHPPHP
If you wonder how to find a proper way of converting MySQL data to JSON format using PHP, then you are in the right place. Read on and check the example.
- How to Convert Object to StringJavaScript
Read this JavaScript tutorial and learn about the fastest methods of converting object into string. Read about JSON.stringify() and toString() methods.
- How to convert the following json string to java object?Java
To convert a JSON string to a Java object, you can use the fromJson method of the Gson class.
- How to Create a jQuery Ajax Post with PHPPHP
Here, we will share with you how to create a jQuery Ajax post request with PHP. Just check out the examples and choose the one that suits your needs best.
- How to Create and Parse JSON Data with PHPPHP
JSON is a data-interchange format, which can be generated and parsed by PHP or other programming languages. See how to create and parse JSON data by PHP.
- How to create correct JSONArray in Java using JSONObjectJava
To create a JSON array using JSONObject in Java, you can use the put() method of the JSONObject class to add elements to the array.
- How to create JSON Object using String?Java
To create a JSON object from a string in Java, you can use the org.json library. Here's an example of how to do this:
- How to decode Unicode escape sequences like "\u00ed" to proper UTF-8 encoded characters?PHP
In PHP, you can use the utf8_decode() function to decode a string that contains Unicode escape sequences.
- How to JSON Decode a String into an Array with PHPPHP
This is a short guideline that provides comprehensive information on how to decode a JSON string into an array with the help of PHP.
- How to make a class JSON serializablePython
In order to make a class JSON serializable in Python, you need to define two methods: __init__ and to_json.
- How to Manage a Redirect Request after a jQuery Ajax CallJavaScript
In this JavaScript tutorial, you will read and learn detailed information about the method used for managing a redirect request after a jQuery Ajax call.
- How to Merge Properties of Two JavaScript Objects DynamicallyJavaScript
Have you ever wanted to merge the properties of two objects in JavaScript dynamically? This tutorial is aimed at showing you how to do it in rational ways.
- How to overcome "datetime.datetime not JSON serializable"?Python
One way to overcome "datetime.datetime not JSON serializable" in Python is to use the json.dumps() method with the default argument, default=str, which converts the datetime object to a string before serializing.
- How to parse JSON in JavaJava
To parse a JSON string in Java, you can use the org.json library. This library provides a simple and easy-to-use interface for parsing and manipulating JSON data in Java.
- How to parse JSON in Kotlin?Java
To parse JSON in Kotlin, you can use the JSONObject class from the org.json package.
- How to POST JSON data with Python Requests?Python
You can use the requests library in Python to send a POST request with JSON data.
- How to prettyprint a JSON file?Python
To pretty-print a JSON file in Python, you can use the json module.
- How to Print a Circular Structure in a JSON-like FormatJavaScript
In this JavaScript tutorial, you will find useful information about the method that is used to format an object to JSON what contains circular structure.
- How to read json file into java with simple JSON libraryJava
To read a JSON file into Java using the Simple JSON library, you can use the JSONObject class and the JSONArray class.
- How to remove backslash on json_encode() function?PHP
You can use the JSON_UNESCAPED_SLASHES option in the json_encode() function to prevent backslashes from being added to the JSON string.
- How to Return JSON from a PHP ScriptPHP
This short tutorial will represent to you the most effective way of returning JSON from a PHP script.
- How to send HTTPS posts using phpPHP
To send an HTTPS POST request using PHP, you can use the curl extension.
- How to upload a file and JSON data in Postman?Java
To upload a file and JSON data in Postman, you can follow these steps:
- How to use Jackson to deserialise an array of objectsJava
Jackson is a powerful Java library for processing JSON data. You can use Jackson to deserialize an array of objects by following these steps:
- How to validate Google reCAPTCHA v3 on server side?PHP
To validate a Google reCAPTCHA v3 on the server side using PHP, you will need to do the following steps:
- Http 415 Unsupported Media type error with JSONJava
A HTTP 415 Unsupported Media Type error means that the server is unable to process the request because the request entity has a media type that the server does not support. In the context of a JSON request, this means that the server is unable to process
- HTTP POST using JSON in JavaJava
To make an HTTP POST request using JSON in Java, you can use the HttpURLConnection class available in the java.net package. Here's an example of how to do it:
- HttpServletRequest get JSON POST dataJava
To get JSON POST data from an HttpServletRequest object in Java, you can use the getReader method of the ServletRequest interface to read the request body as a BufferedReader and then use the readLine method to read the data as a string.
- Ignoring new fields on JSON objects using JacksonJava
If you want to ignore new fields on JSON objects when using Jackson, you can use the @JsonIgnoreProperties annotation on your Java object.
- Is there a list of Pytz Timezones?Python
Yes, you can use the all_timezones attribute of the pytz library to get a list of all the timezones that it supports.
- Is there Java HashMap equivalent in PHP?PHP
In PHP, the equivalent to a Java HashMap would be an associative array.
- Issue reading HTTP request body from a JSON POST in PHPPHP
In PHP, you can read the body of an HTTP request using the file_get_contents('php://input') function.
- Jackson with JSON: Unrecognized field, not marked as ignorableJava
If you are using the Jackson library to parse JSON in Java and you get the error "Unrecognized field, not marked as ignorable", it means that you are trying to parse a JSON object that has a field that is not recognized by your Java object.
- JAX-RS — How to return JSON and HTTP status code together?Java
In JAX-RS, you can use the Response class from the javax.ws.rs.core package to return a JSON response and an HTTP status code together. Here's an example of how to do this:
- json_decode to custom classPHP
In PHP, you can use the json_decode() function to convert a JSON string into a PHP object or array.
- JSON_ENCODE of multidimensional array giving different resultsPHP
JSON_ENCODE is a function that converts a PHP data structure, such as an array, into a JSON (JavaScript Object Notation) string.
- JSONDecodeError: Expecting value: line 1 column 1 (char 0)Python
The error message "JSONDecodeError: Expecting value: line 1 column 1 (char 0)" typically occurs when you are trying to parse a string as JSON, but the string is not in a valid JSON format.
- Parsing JSON Object in JavaJava
To parse a JSON object in Java, you can use the org.json library.
- Parsing JSON string in JavaJava
To parse a JSON string in Java, you can use the JSONObject class from the org.json package.
- PHP & localStoragePHP
PHP is a programming language that is often used to build web applications.
- PHP CURL DELETE requestPHP
To send a DELETE request with PHP using cURL, you can use the following code:
- PHP Fatal error: Call to undefined function json_decode()PHP
This error usually occurs when you are trying to use the json_decode() function, which is used to decode a JSON string into a PHP variable, but the function is not available.
- PHP returning JSON to JQUERY AJAX CALLPHP
To return JSON from a PHP script to a jQuery AJAX call, you can use the json_encode() function in PHP to convert an array or object into a JSON string.
- POST request via RestTemplate in JSONJava
To make a POST request with the RestTemplate in JSON, you can use the postForObject() method and pass it the URL of the request, the request body, the response type, and the HttpEntity object that represents the request headers and body.
- Printing Lists as Tabular DataPython
Here is an example of how to print a list of lists (a 2D list) as tabular data using Python:
- Reading JSON from a filePython
Here is an example of reading a JSON file in Python:
- Returning JSON object as response in Spring BootJava
To return a JSON object as a response in Spring Boot, you can use the @ResponseBody annotation and the ObjectMapper class.
- Save PHP array to MySQL?PHP
To save a PHP array to a MySQL database, you can use the serialize() function to convert the array into a string, and then use an INSERT or UPDATE statement to save the string into a TEXT or LONGTEXT field in the database.
- Serializing with Jackson (JSON) - getting "No serializer found"?Java
If you are getting the error "No serializer found" when trying to serialize an object to JSON using Jackson, it usually means that Jackson does not know how to serialize one or more fields in the object.
- Simplest way to read JSON from a URL in JavaJava
To read JSON from a URL in Java, you can use the readJsonFromUrl() method from the JSON simple library.
- Spring MVC - How to return simple String as JSON in Rest ControllerJava
To return a simple string as JSON in a Spring MVC Rest Controller, you can use the @ResponseBody annotation and return the string directly.
- Sum a list of numbers in PythonPython
Here is a code snippet that demonstrates how to sum a list of numbers in Python:
- The “right” JSON Date FormatJavaScript
Read the tutorial and learn the right methods of JSON date formatting with the help of JavaScript. Get to know information about ISO 8601 string format.
- What is a clean "pythonic" way to implement multiple constructors?Python
A "pythonic" way to implement multiple constructors in Python is to use the @classmethod decorator.
- What is the Difference Between JSON.stringify and JSON.parseJavaScript
Read this JavaScript tutorial and learn about two useful JSON methods that are used for converting JavaScript object into string and vice versa easily.
- When is the @JsonProperty property used and what is it used for?Java
The @JsonProperty annotation is used to specify the property name in a JSON object when serializing or deserializing a Java object using the Jackson library.
- Why can't Python parse this JSON data?Python
Without a specific code snippet and the JSON data that is causing issues, it is difficult to determine why Python is unable to parse the data.