How-to articles, tricks, and solutions about JSON

Parsing JSON string in Java

To parse a JSON string in Java, you can use the JSONObject class from the org.json package.

PHP Fatal error: Call to undefined function json_decode()

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 json_decode() returns NULL with seemingly valid JSON?

There are a few possible reasons that json_decode() might return NULL when given what appears to be valid JSON.

PHP returning JSON to JQUERY AJAX CALL

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 JSON

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.

Reading JSON from a file

Here is an example of reading a JSON file in Python:

Returning JSON object as response in Spring Boot

To return a JSON object as a response in Spring Boot, you can use the @ResponseBody annotation and the ObjectMapper class.

Serializing with Jackson (JSON) - getting "No serializer found"?

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 Java

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 Controller

To return a simple string as JSON in a Spring MVC Rest Controller, you can use the @ResponseBody annotation and return the string directly.

The “right” JSON Date Format

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.

UnicodeDecodeError: 'utf8' codec can't decode byte 0xa5 in position 0: invalid start byte

This error occurs when trying to decode a byte string using the UTF-8 codec and the byte at the given position is not a valid start byte for a UTF-8 encoded character.

What is the Difference Between JSON.stringify and JSON.parse

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 to Use Double or Single Quotes in JavaScript

Almost all JavaScript developers come across the issue: when to use double or single quotes. Here, we explore possible cases, offering rational solutions.

Why am I seeing "TypeError: string indices must be integers"?

The "TypeError: string indices must be integers" error is raised when you try to access an element of a DataFrame or Series using a string index instead of an integer index.

Why can't Python parse this JSON data?

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.

1 2 3