Questions tagged [json]

JSON (JavaScript Object Notation) is a serializable data interchange format that is a machine and human readable. Do not use this tag for native JavaScript objects or JavaScript object literals. Before you ask a question, validate your JSON using a JSON validator such as JSONLint (https://jsonlint.com).

JSON (JavaScript Object Notation) is a serializable data interchange format intended to be machine- and human-readable.

JSON is defined by RFC 7159 which is completely language independent, but it uses conventions familiar to programmers of the C-family of languages, including , , , , , , , and many others. These properties make JSON an ideal data-interchange language to use with RESTful APIs or . It is often used instead of because of its lightweight and compact structure.

Many programming languages provide methods for parsing a JSON-formatted text string into a native object and vice versa. For example, JavaScript in modern browsers and other environments includes the methods JSON.parse() and JSON.stringify().

The JSON format is based on two types of structures:

  • Collection of name/value pairs

    {"name1":"value1", "name2":"value2"}
    
  • An ordered list of values (more commonly referred to as an array)

    ["value1", "value2"]
    

JSON defines six types of values: null, numbers, strings, booleans, arrays and objects. With regard to objects, the order of members is not significant, and the behaviour of a JSON parser when duplicate member names are encountered is undefined.

Note that JSON is not the same thing as JavaScript object literals. Instead, JSON is a standard format to serialize from and deserialize objects in most languages. For more information, see There is no such thing as a JSON object in JavaScript.

Shortly after it was created, JSON validation was added following the description set out by Douglas Crockford of json.org in RFC 4627. It has since been expanded to validate both current competing JSON standards RFC 7159 and ECMA-404.


Advantages

  • JSON is a lightweight data-interchange format (no markup bloat)
  • JSON is language independent.
  • JSON is "self-describing" and easy to understand.
  • JSON can be natively understood by JavaScript parsers, including node.js

JSON libraries


Browser Addons


Useful links


Books


See also

357960 questions
56
votes
6 answers

How to solve JSON_ERROR_UTF8 error in php json_decode?

I am trying this code $json = file_get_contents("http://www.google.com/alerts/preview?q=test&t=7&f=1&l=0&e"); print_r(json_decode(utf8_encode($json), true)); ////////////// // Define the errors. $constants =…
James Harzs
  • 1,853
  • 5
  • 21
  • 30
55
votes
7 answers

Test if it is JSONObject or JSONArray

I have a json stream which can be something like : {"intervention": { "id":"3", "subject":"dddd", "details":"dddd", "beginDate":"2012-03-08T00:00:00+01:00", …
Tang
  • 675
  • 1
  • 7
  • 10
55
votes
2 answers

How can I construct and parse a JSON string in Scala / Lift

I am attempting to use JSON to send data between the browser and my app. I am attempting to use Lift 1.0 to create and parse JSON strings, but for some reason I am unable to parse the JSON I just constructed: scala>import…
David Carlson
  • 1,461
  • 2
  • 18
  • 18
55
votes
7 answers

How can I read the appsettings.json in a .NET 6 console application?

I try to create a .NET 6 Console Application but having troubles reading my appsettings.json file. In a web application I could use this... var builder = WebApplication.CreateBuilder(args); But what would I use in a console application? I get this…
MTplus
  • 2,077
  • 4
  • 34
  • 51
55
votes
7 answers

Simple jQuery, PHP and JSONP example?

I am facing the same-origin policy problem, and by researching the subject, I found that the best way for my particular project would be to use JSONP to do cross-origin requests. I've been reading this article from IBM about JSONP, however I am not…
Jeff
  • 12,085
  • 12
  • 82
  • 152
55
votes
4 answers

Deserializing JSON into object with overloaded methods using Jackson

I am attempting to deserialize a JSON object stored in CouchDb using Jackson. This object needs to deserialize into a pojo that contains overloaded methods. When I attempt to retrieve the object from couch and do the deserialization I get the…
gregwhitaker
  • 13,124
  • 7
  • 69
  • 78
55
votes
5 answers

How do I use JSON.NET to deserialize into nested/recursive Dictionary and List?

I need to deserialize a complex JSON blob into standard .NET containers for use in code that is not aware of JSON. It expects things to be in standard .NET types, specifically Dictionary or List where "object" can be…
dongryphon
  • 705
  • 1
  • 5
  • 8
55
votes
1 answer

Has Json tag but not exported

Begining to study golang. Task: Get Json and Unmarshall it. But I get mistake: Json tag but not exported How to make unexported fields become exported and then implement it using methods? Here is the code: package main import ( …
frostrock
  • 789
  • 1
  • 5
  • 11
55
votes
11 answers

Is parsing JSON faster than parsing XML

I'm creating a sophisticated JavaScript library for working with my company's server side framework. The server side framework encodes its data to a simple XML format. There's no fancy namespacing or anything like that. Ideally I'd like to parse all…
geme_hendrix
  • 917
  • 1
  • 7
  • 9
55
votes
5 answers

XMLHttpRequest cannot load an URL with jQuery

I'm trying to get some json data from a "remote" website. I run my web service on the 99000 port then, I launch my website on the 99001 port (http://localhost:99001/index.html). I get the following message: XMLHttpRequest cannot load…
Zakaria
  • 14,892
  • 22
  • 84
  • 125
55
votes
3 answers

How to parse JSON from the Invoke-WebRequest in PowerShell?

When sending the GET request to the server, which uses self-signed certificate: add-type @" using System.Net; using System.Security.Cryptography.X509Certificates; public class TrustAllCertsPolicy : ICertificatePolicy { public…
user52028778
  • 27,164
  • 3
  • 36
  • 42
55
votes
3 answers

How to use jq when the variable has reserved characters?

I'm trying to get the following to work and it's not, help me please: curl -s 'https://cryptofresh.com/api/asset/markets?asset=MKR' | jq .OPEN.BTC The variable in question includes a period, I tried just about everything to escape the period &&…
Jonny Gerold
  • 551
  • 1
  • 4
  • 3
55
votes
3 answers

Fastest JSON reader/writer for C++

I need a C++ JSON parser & writer. Speed and reliability are very critical, I don't care if the interface is nice or not, if it's Boost-based or not, even a C parser is fine (if it's considerably faster than C++ ones). If somebody has experience…
user424060
  • 1,545
  • 3
  • 20
  • 29
55
votes
5 answers

Iterating through a JSON file PowerShell

I am trying to loop through the below JSON file in PowerShell. Without specifically naming the top tags (e.g. 17443 and 17444), as I do not know them in advance I cannot find a way to loop through the data. I want to output tags 3, 4 and 5 (title,…
Omen9876
  • 721
  • 1
  • 5
  • 7
55
votes
9 answers

Reading json files in C++

I'm trying to read in a JSON file. So far I have focused on using the jsoncpp library. However, the documentation is quite hard to understand for me. Could anyone explain in lay terms what it does? Say I have a people.json which looks like…
user3515814
  • 957
  • 2
  • 8
  • 13
1 2 3
99
100