Questions tagged [json]

JSON (JavaScript Object Notation) aka the Fat Free Alternative to XML is a lightweight data exchange format inspired by JavaScript object literals. It is often used with JavaScript, Ajax, and RESTful web services but is completely language independent.

Filter by
Sorted by
Tagged with
9
votes
2answers
309 views

Adding to a finite set of options; an API breaking change?

Take an HTTP API endpoint which spits out the following response model: { "type": "Dog", "name": "Jessi", ... } The type field has been described in the documentation as being one of Dog,...
17
votes
1answer
9k views

Why do Microsoft's libraries depend on Newtonsoft.Json?

This had probably started way back when Microsoft created ASP.NET Web API library, at least that's when I remember it if I am not mistaken. Anyway, since then, its HTTP packages started depending on ...
3
votes
4answers
583 views

How to design HTTP endpoint which search for single resource instance and returns it with another, connected instance

I have an endpoint returning single-element collection (I didn't return just object-instance to keep consistent with resource-as-collection convention, so only get-by-id returns single instance) GET ...
4
votes
2answers
1k views

How to define and share a JSON schema between the front-end and back-end of an application?

We have a mobile app that accepts input into some fields, formalises them as a JSON document and then sends it to the back-end for processing. We want to agree on a schema for this document that can ...
1
vote
5answers
830 views

Define a RESTful API for creating/updating other resource definitions?

Let's say I have a users resource, with two properties: name and email as specified by a users JSON Schema document, which right now looks like this: { "$schema": "http://json-schema.org/draft-04/...
1
vote
1answer
49 views

How to avoid fetching additional informations when instantiating objects

I'm creating an HTML5 game using javascript and have got some problems during the first instantiation of the objects of the scene. Scenario Self-written 2d game engine that supports multiple ...
3
votes
1answer
2k views

Serialize Entity Framework Objects Without Lazy Loading

I have a very specific scenario that I'm not sure is possible to fully support: I have an ASP.NET application that uses Entity Framework 6.3 for it's data management. I also have a generic audit ...
1
vote
1answer
108 views

JSON APIs in PHP, across the internet

I am building a proof of concept for data processing web service, that allows users to get data cleaned, homogenized or otherwise manipulated. Often users send different types of data in the same ...
7
votes
1answer
835 views

Reusing a top-level DTO as a child in another DTO

What is the recommendation regarding re-using DTO's as a child in another DTO? I'm using ASP.NET Web API (C#) and consuming the results with Angular 1.x (not sure if that really matters). I have the ...
1
vote
1answer
290 views

How to structure JWT correctly

I'm designing a JWT authentication workflow for a RESTful API which uses two kinds of tokens: Phone token, a short-lived token - issued by completing an One-Time-Password challenge. Its task is to ...
1
vote
0answers
45 views

How to handle an api with severe technical debt? [duplicate]

Our company uses another companys api. This api is written using IBM domino. This api is horrifically inconsistent and outdated. E.g. sometimes returning JSON, sometimes html. Inconsistent naming and ...
-7
votes
1answer
149 views

Parsing odd JSON Request [closed]

I know how to parse normal JSON objects using the org.json library, but I am confused as how I would parse this one as it has no array/object names. [ { "value1": null, "value2": ...
1
vote
0answers
83 views

Choice of response type in web application architecture

I've been using various server side languages/frameworks for developing back-end web applications. Every server-side framework that I've been using has the capability for returning views/templates (...
6
votes
1answer
3k views

How does Microdata rdfa compare to JSON-LD?

The bottom of the Wikipedia "talk" page says that Microdata is dead, and superseded by rdfa and json-ld. What is the difference between the formats (or value), and which one should be used? I'm ...
1
vote
1answer
1k views

Storing uploaded images for website

I'm developing a website (using PHP, JS, and MYSQL) which allow user to upload images. My requirements are as below: User is able to upload 1 or multiple images at a time. Website is able to save ...
5
votes
1answer
5k views

REST API: Handle “partial” nested objects

Let's say we have schools with some data including a name and a list of students, and students with some data including courses they're enrolled in and a reference to their school. On the client: I'd ...
1
vote
1answer
794 views

REST API responding with nested arrays

I would like to know the best practice for designing a REST API for a resource that has a has_many relationship with another resource. In my app, companies have many technologies, and technologies ...
1
vote
0answers
676 views

Best practices for encoding information in URL

I have implemented a tracking pixel that is simply an img tag that another party puts on their website. This works by making the src refer to our endpoint with query params set with extra information. ...
1
vote
1answer
785 views

Loading data from JSON file for one time

I have JSON file which has some hundereds of rows stored like below.. [ { "Id": "1", "Name": "A" }, { "Id": "1", "Name": "A" } ] I am trying to load this into collection of a ...
1
vote
2answers
901 views

jersey post with a huge payload

I have a requirement to write a POST endpoint where the payload is huge(not normal). In the order 10s of Megabytes. And this endpoint will be accessed by a lot of clients (in the order of 1000s) ...
0
votes
1answer
2k views

How to deal with automatic binding exceptions with Jersey?

It's really nice to have automatic binding with Jersey-Jackson (well, I believe it's actually MOXy the one who manages the bindings), so object serialization and deserialization is done under the hood....
3
votes
3answers
195 views

GET resource state with JSON body or HTTP code

I want to provide rest api for my iot service to read state of a sprinkler on/off. So far I've come up with two solutions: GET /api/sprinkler that returns 204 if on and 404 if off GET /api/sprinkler ...
7
votes
3answers
12k views

How to represent object references in JSON?

I am trying to figure out what's the best approach when dealing with object references in a JSON to be sent to my server for deserialization. To clarify, what I mean is how to refer to data contained ...
21
votes
4answers
61k views

What JSON structure to use for key value pairs?

What JSON format is a better choice for key value pairs and why? [{"key1": "value1"}, {"key2": "value2"}] Or: [{"Name": "key1", "Value": "value1"}, {"Name": "key2", "Value": "value2"}] Or: {"key1"...
1
vote
0answers
115 views

Two classes which are supposed to be the same, but differ in lists

I am using a 3rd party API which yields JSON which has two ways of loading data - as a list of items, or as a singular item. The problem is that a given item in the list has different properties than ...
0
votes
2answers
10k views

How do you deal with NULL values while creating JsonObject?

I am learning Java and JSR-353. My question is quite forward. Having the method below: public JsonObject createJsonObject() { return Json.createObjectBuilder() .add("address", this....
0
votes
1answer
521 views

Are there any JSON based notations for Access Control Lists? (Alternative to S-Expression)

I'm looking for a notation that is familiar to modern developers and can supersede s-Notation. (additional insight into Rivest's proposal of s-Expression is here) Is there any Swagger, JSON or other ...
10
votes
3answers
12k views

Is it bad practice to use hyphens in JSON keys?

I see a lot of questions revolving around accessing JSON keys that use hyphens (kebab-case), but now I find myself wondering should I just stick to camelCase or snake_case in my keys. I know hyphens ...
6
votes
4answers
3k views

JSON API or Plain JSON

There is a debate in my company on whether we should use the JSON API specification or stick to plain JSON for developing APIs that will be consumed by mobile apps, mainly iOS and Android. One ...
1
vote
1answer
665 views

Data Storage Architecture: Storing Hierarchical Data (JSON/BSON)

Say you have the hierarchical storage concept of "Foo." "Foo" holds an id, various values, and zero to many "Foo." Obviously, in turn, the child elements can hold zero to many Foos. The data is purely ...
3
votes
1answer
370 views

Dynamic form builder with serialised SQL persistence

I have a requirement whereby my users will need to be able to build their own forms. Which they can specify different datatypes: Text DateTime Checkboxes All customisable mandatory/optional. I've ...
1
vote
2answers
376 views

Creating a web application with full text search on dynamic data

Even after thorough requirements engineering we end up with users wanting to attach 'notes' to their otherwise well-structured data records, in other words: arbitrary key-value pairs. Their primary ...
1
vote
1answer
92 views

Transfer flattened entities instead of DTOs?

I wonder, if the below idea makes sense for our web application. We show various lists of entities, which typically refer to other entities and so on. In the table view, there are columns showing some ...
3
votes
0answers
918 views

Best way to build a JSON API coupled with HTML views in a Rails project

I've got a Rails eCommerce project communicating with an iOS app. The iOS app receives JSON data from the Rails back-end, but there's also HTML rendering when a user comes to the project from his ...
0
votes
2answers
616 views

JSON or XML or other - most time efficient for largely “read” of structured data

Considering that using a relational DB or other hierarchical or such databases is not an option, looking for the alternative approach using a simple (but very fast, efficient, distributed KV-store). ...
2
votes
2answers
2k views

Is it a bad practice to use JSON strings as keys of objects?

On languages such as Haskell, most datatypes have instances which allow their values to be used as keys of structures such as Maps. JavaScript has reasonably fast maps, there called objects, but those ...
2
votes
2answers
454 views

Modelling a REST Object Question (Python)

I have a REST API that I want to model in a class so I can access the properties using the dot notation (JS list notation). I explicately defined the properties on my class using the @property tags ...
2
votes
3answers
174 views

What is the least bad way of knowing the type of a key from Json file

in our app we have a Json file that contains several properties used for menu configuration. One of the keys should tell us if a menu item should be displayed. The thing is that the value for this key,...
2
votes
2answers
182 views

Reversible Functions

Currently writing a JSON Importer and creating some POJOs based on the data. I also have a requirement to write an JSON Exporter which take the information in the POJOs and exports a JSON doc. To me ...
-1
votes
3answers
2k views

Dealing with API rate limits

I've been using a simple json to the steam API to get player inventory, but now I have discovered that steam impose a rate limit to the number of requests allowed. A rate I feel is not enough for my ...
5
votes
2answers
2k views

Whether to embed linked resources in REST API

I am building a REST API where clients can query user-sent messages, like this: GET http://example.com/api/v1/messages?from=0&to=100 Response: [ { "id": 12345, "text": "...
0
votes
1answer
760 views

multiple api calls vs more complex apis

I have been providing a Web API (.NET MVC 5) of an Oracle Database to people who are making a mobile app. I have to admit that I am not very good at it. I have found that I can easily produce Data ...
-1
votes
1answer
580 views

Considerations about returning text instead of JSON in a JSON compliant API [closed]

I'm using Spring-Boot + Jackson to implement a Rest API. When I return some object from my methods the controllers are building a JSON compliant response. However, that's not happening when I return ...
3
votes
1answer
2k views

JsonAPI - Updating the relationship for a resource

I am having trouble understanding http://jsonapi.org/. Say, I have the following endpoints in my API for authors and articles. /authors /authors/:id/articles If I wanted to fetch the details ...
0
votes
2answers
61 views

How to model a property with two different formats and ranges

I am designing a JSON based data schema to describe the visual appearance of blocks similar to HTML elements. It should feel familiar for somebody knowledgable in HTML/CSS but is more restrictive due ...
5
votes
1answer
1k views

How are JSON Web Token validators tested?

JSON Web Tokens (JWTs) are an open, industry standard method for representing claims securely between two parties. There are numerous implementations for JWT verification, but it looks like each ...
0
votes
1answer
332 views

Parsing JSON and creating analytics out of the data, what is the best way to do it?

I am on a project where I call an API and I want to make statistics with the data returned. It returns a big .json object. As that is not possible to flatten, and I am not interested on all the data ...
2
votes
2answers
542 views

Why use JSON dataset rather than SQL Query?

A colleague was asking me to explain a system information flow, as they are having problems with the wrong information being presented. It seems that what they have created is a custom built website, ...
1
vote
2answers
124 views

Secure authentication using JWT

I read about JWT and how they can provide secure authentication for calling api routes over http. I naively implemented it and here is how it goes : a client posts username and password to a login ...
-1
votes
3answers
1k views

What is a correct way to exchange information between “frontend” and “backend”? [closed]

I am not so experienced in client-server applications and I could not find exactly answer to my question anywhere in google. I am developing part of application on server side and my collegue who ...