What is JSONC? Are JSONC and JSON-C different? - json

Recently came across the term JSONC in a YouTube API. I browsed the Web, but found nothing much about it. Can someone explain whether these two are the same or different?

There is also jsonc aka "JSON with comments", created by Microsoft and used by Visual Studio Code. The logic for it can be found here, alas without exhaustive specification (though I'd like to be proven wrong on this).
On top of that there is this project with an actual specification which is also called jsonc, but also does far more than just adding comments.
While there definitely is a use for these technologies, some critical thinking is advised. JSON containing comments is not JSON.

JSON-C seems to just be a variation of JSON mainly targeted at C development. I.e., from the open source docs, "JSON-C implements a reference counting object model that allows you to easily construct JSON objects in C, output them as JSON formatted strings and parse JSON formatted strings back into the C representation of JSON objects."ref^1
From the YouTube API perspective (specifically, version 2, not the new version 3), The JSON-C response is just a condensed version of the JSON response (removing "duplicate, irrelevant or easily calculated values").ref^2
Why would the JSON response have "duplicate, irrelevant or easily calculated values" values anyway? Because it is converting the original ATOM XML format directly to JSON in a loseless conversion. You can find out more details here.
However, I would suggest using version 3 of the YouTube Data API. It is much easier to use. =)

JSONC is an open-source, Javascript API created by Tomás Corral Casas for reducing the size of the amount of JSON data that is transported between clients and servers. It uses two different approaches to achieve this, JSONC.compress and JSONC.pack. More information can be found on the JSONC Github page:
https://github.com/tcorral/JSONC

Related

How the JSON was developed and what was the technology used to development

In our project we start using JSON file, when i start research on What the JSON is and where it comes from, What is the technology they have used, is it only javascript or anyother and which parsing tool they have used,but i didn't get any clear information. If anyone have such reference document and ideas please give me link .
JSON is just a data exchange format, like xml, csv...
Even if it's part of JavaScript it's not restricted to JS. JSON can be used in nearly every language and im pretty sure, every good language have a parser implementation in place. json.org lists a overview of projects related to JSON.
As you asked for links to information:
(Complete Overview)
http://json.org/
(Douglas Crockford 'The JSON Saga') https://www.youtube.com/watch?v=-C-JoyNuQJs
(ECMA Standard that defines JSON) http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf

converting json string to texteditor

i am a real noob. The thing is, i dont know where to turn. we, as in myself and my thesis partner are trying to build (theoreticly) a platform which has an own search engine directed only at the databases of wikipedia. Now when you download articles or an article, using the wikipedias api you get a json formatted string, now the question is how do i convert that json code string into just text?
like a plain simple english?
and if you have any suggestions on search algorithms for the search engine that would also be helpfull.
(note) if you can give me an explanation otherwise just give directions on keywords to search for
You would typically use a function to convert that json to object and then take the property that is of interest to you.
pseudo code:
function getTextFromwikiArticleJson(json){
var realobject = JSON.decode(json);
return realobject.content.body;
}
JSON is just (one of) the format(s) used to transfer data over internet. It then needs to be processed (i.e. parsed) in order to extract the information you want.
A wikipedia API call might give you much more information than you actually want (so called meta-data), such as creation date, authors, etc.
You are probably interested in the text of the article, so you need to access the corresponding entry in the JSON.
Try pasting the JSON in an online parser, such as https://jsonformatter.org/json-parser.
Also, read about JSON here: https://en.wikipedia.org/wiki/JSON
Most programming languages have functions to parse JSON data (often via external libraries, such as gson for Java, for example)

Processing hugely varied JSON data from Facebook Graph API news feed

OK so I have authenticated fine and understand JSON including how to process it with PHP...
http://php.net/manual/en/function.json-decode.php
But my issues are that the JSON data that the API returns after hitting up FB...me/home end point is very varied. I understand that so is the data on a FB news stream but...
My end game is to show this info in a mash-up with other data but there seems no clear way of formatting it and each item in the JSON response is hugely different with different values. No consistent "item_type" : "photo / status update / message" that I could use to template it up into nicely formatted content blocks on the front end?
Any suggestions on the best way to process / style this type of vary varied JSON?
Thanks.
I would suggest checking out Google's gson library for parsing through JSON documents. Assuming that you are familiar with Java it makes it relatively easy to develop a custom parser that can adapt to documents stored under a flexible schema.
The library page is here. You can find the JsonReader documentation here.
Edit: It also might help to post some example documents so we can get a better idea of what kinds of results you're getting.

How to encode JSON in ABAP before 7.02

As Horst Keller mentioned in his ABAP and JSON post, "with Releases 7.02 and 7.03/7.31 (Kernelpatch 116) JSON is supported natively in ABAP".
Appartently 7.02 in my case of too generic because the line below:
writer = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
returns the error: "The field CO_XT_JSON is unknown, but there is a field with the similar name CO_XT_XOP".
So is there any way to easily generate JSON?
Edit: Screenshot from SAP - Status
About the class CL_TREX_JSON_SERIALIZER: I also used this class during developping a mobile sap application and I found the created JSON not being valid, thus I started googling and found this http://scn.sap.com/community/mobile/blog/2012/09/24/serialize-abap-data-into-json-format (which also explains how to create a valid JSON serializer).
Validate your json with json lint http://jsonlint.com/ to see if it is valid.. otherwise, thats for sure, you get a lot of trouble in debugging why it doenst work and dont get the point that the serializer is corrupt. regards, zY
take a look at the ZCL_MDP_JSON Library. You can parse/encode any JSON. So, it is best suited for JSON scenarios that requires flexibility.
It is easy to understand if you have used JSON in other languages. You only need to study methods of ZCL_MDP_JSON_NODE class once & look at the examples.
Here is an extended overview of the library:
http://scn.sap.com/community/abap/blog/2016/07/03/an-open-source-abap-json-library--zclmdpjson
GitHub repo with examples directory: https://github.com/fatihpense/zcl_mdp_json
Disclaimer: I'm the author of the project. If you have questions, don't hesitate to contact me.
Here is some code I wrote for ABAP data <-> JSON conversion some time ago before the new capabilities were included with ABAP (or maybe it was just an older system).
https://gist.github.com/mydoghasworms/2291540
Include the code in your ABAP source and use the method data_to_json of the class.
A nice overview of custom ABAP <-> JSON serializers including yet another one can be found in this blog post
Most popular from my point of view is SE38's ZJSON-library which can be installed using SAPLINK (and which - in contrast to many others) has an explicit license attached to it: Apache 2.0
If upgrading to a newer patch isn't an option in the short term, you can also use class CL_TREX_JSON_SERIALIZER to serialise objects to JSON. A little bit of a quick-and-dirty solution but it works well.

Is it possible to parse a Google+ (Google Plus) profile page?

If you view the source of a Google+ profile page, it appears rather complex. It seems most of the data is kept in a huge JSON-like objects. However, they don't seem to be really JSON, since they don't get recognized when I try to decode them. I am hoping the format is more clear to other people here. How would you go about parsing it? It seems it would fairly trivial, if you know where to start.
Here is a sample profile, for example: http://plus.google.com/104560124403688998123
Here's a PHP API I'm working on. It can download and parse the data for a profile page and people's public relationships.
https://github.com/jmstriegel/php.googleplusapi
The JSON piece is a bit mangled. To generate valid JSON, you basically have to remove the first 5 characters that prevent XSRF attacks and then add in all the nulls that have been removed. Here's the code specific to handling parsing the weird Google Plus JSON responses:
https://github.com/jmstriegel/php.googleplusapi/blob/master/lib/GooglePlus/GoogleUtil.php
Call GoogleUtil::FetchGoogleJSON( $url ) and you'll get back a giant array that you can then pull data from. Using this, it should be trivial to make a proxy service to translate stuff into valid json(p) for you to use in your own apps.
I don't have access to Google+ yet, so I'll just answer the general question - that is, how to parse JSON.
JSON is just JavaScript, so parsing it is as simple as evaluating the script. To do this, use the eval() JavaScript function.
var obj = eval('{"JSON":"goes here"}');
Another option is to leverage a console tool. Popular modern browsers pretty much all have them. I recommend Firebug for Firefox in particular.
Using Firefox, log into Google+, then open the Firebug console. You can use the console's dir() command to create a browseable representation of the data. Ex:
console.dir(eval('{"JSON":"goes here"}'));
Sorry I can't be more specific about how to get a handle on Google+'s JSON in particular; without access to the service, this is about the best I can do blind. Good luck!
Thanks to Jason for the excellent php class which reads a profile page into an array.
I've used this class as a base and then parsed it, based upon Russell Beattie's python code from the original appspot rss feed application.
Code here
A few notes:
I use this to merge G+ and WP feeds, hence writing posts into an intermediate array ($items).
I have a convention of creating a pseudo title in Google Plus posts, by emboldening a line and adding two newlines before writing the post. The function getTitle strips this out as a better formatted title in my website and getSummary produces the rest of the post with duplicating the title.
It's made up of a number of parts, an object describing your picasa images, one describing the fields on your profile, one describing your friends.
Most of the long numbers are the internal IDs of people, posts and photos. For instance, my ID is 105249724614922381234. Other than that, it could be parsed if you needed to.