Live data from Hacker News

JSON Feed

jsonfeed.org

201–210 of 225 posts

Re: JSON Feed

#201

Earlier quoted context omitted.

Yikes, you didn't even make it to the second sentence. > JSON is simpler to read and write, and it’s less prone to bugs.

JSON is simpler to read and write, and it’s less prone to bugs. I don't actually find either of those things to be true.

That's a fine opinion to have, but that doesn't mean that people (the authors or devs generally) use JSON out of vanity. As an aside, you're the first person I've heard suggest people put their identity in serialization format, which gave me a good laugh.

Re: JSON Feed

#202
Is this a "JSON Feed" from NYTimes?

Example below filters out all URLs for a specific section of the paper.

   test $# = 1 ||exec echo usage: $0 section

   curl -o 1.json https://static01.nyt.com/services/json/sectionfronts/$1/index.jsonp
   exec sed '/\"guid\" :/!d;s/\",//;s/.*\"//' 1.json
I guess SpiderBytes could be used for older articles?

Personally, I think a protocol like netstrings/bencode is better than JSON because it better respects the memory resources of the user's computer.

Every proposed protocol will have tradeoffs.

To me, RAM is sacred. I can "parse" netstrings in one pass but I have been unable to do this with a state machine for JSON. I have to arbitrarily limit the number of states or risk a crash. As easy as it is to exhaust a user's available RAM with Javascript so too can this be done with JSON. Indeed they go well together.

Re: JSON Feed

#203

Earlier quoted context omitted.

> (And I wonder how long time it will take before the JS-world re-implements this XML-wheel, while again doing so with a worse implementation) I'm going to guess never . I'm also going to guess that there isn't a single flamewar in the entire history of JSON where someone was trying to figure out how to implement anything close to XML namespaces in JSON. And by "close", I mean something that would require changes to…

You never know. This is what they said about schemas too not many years back.

Have there been any discussions whatsoever about adding some sort of namespacing mechanism to JSON?

Re: JSON Feed

#204
post #168
post #76

If we're going to talk about replacing XML with better data formats, why not switch to S-expressions? (feed (version https://jsonfeed.org/version/1) (title "My Example Feed") (home-page-url https://example.org) (feed-url https://example.org/feed.json) (items (item (id 2) (content-text "This is a second item.") (url https://example.org/second-item)) (item (id 1) (content-html " Hello, world! ") (url https://example.or…

Those two aren't comparable because you cannot distinguish between key:val pairs and lists. You need dotted lists.

Nope, one would normally write the code which parses such S-expressions such that the first atom in each list indicates the function to use to parse the rest of the list. So there'd be a FEED-FEED function which knows that a feed may have version, homepage URL &c., and there'd be a FEED-ITEMS function which expects the rest of its list to be items, a FEED-ITEMS-ITEM function which knows about the permissible components of an item &c.

If you really want to do a hash table, you could represent it as an alist:

    (things
      (key1 val1)
      (key2 val2))
This all works because — whether using JSON, S-expressions or XML — ultimately you need something which can make sense of the parsed data structure. Even using JSON, nothing prevents a client submitting a feed with, say, a homepage URL of {"this": "was a mistake"}; just parsing it as JSON is insufficient to determine if it's valid. Likewise, an S-expression parser can render the example, but it still needs to be validated. One nice advantage of the S-expression example is that there's an obvious place to put all the validation, and an obvious way to turn the parsed S-expression into a valid object.

Re: JSON Feed

#205
post #190

Earlier quoted context omitted.

Ok, I have no idea who these guys are so forgive me being rude: if they're so good then why did they not address those points? to my eyes, op makes a solid argument. I'd like to know their side of the story.

But they did... > Badly formed XML? Check. There might be badly formed JSON, but I tend to think it'll be a lot less likely. The problem with XML is mostly that it is a very complex format so the bugs are more probable and there are more pitfalls. > Need to continually poll servers for updates? Miss. Without additions to enable pubsub, or dynamic queries ... They actually did add tags to enable WebSub (previously cal…

I don't agree with most of what you wrote, but the "it's called HTML tags" is the most wrong. You must not have tried this any time in the past 5 years or so. The embedded tags come out of CMSs and - when they're not stripped completely - look like and . HTML isn't used alone, it's always used with CSS nowadays, and no matter if semantic tags are best practice, the fact is it's optional and regularly not used. If they're going to create a new standard format, they need to address this.

Re: JSON Feed

#206
post #104
post #97

Earlier quoted context omitted.

So we can ditch media types altogether then? What's the point of having actual contracts if all we need is a hand shake and a wink? We're not talking about malformed data here, that's something different entirely and yes – it happens all the time. We're talking about calling a spade a spade. If it's JSON your program expects then I should be able to throw any valid JSON at your program and it should work. Granted, it…

I'm not sure what you're arguing. JSONFeed is JSON, unless I'm missing something, just JSON that matches a specific schema. If I'm pulling JSON from any API, I expect it to match a certain schema. If I expected { "time": 10121} from a web API they send me "4", then sure, that's valid JSON, but it doesn't match the schema they promised me in the API. Something that's JSON should be marked JSON, even if we're expecting…

this tool may help to validate and format JSON data, https://jsonformatter.org

Re: JSON Feed

#207

Earlier quoted context omitted.

He said appropriate XML parser. All languages have XML parsers, it's more that a lot suck, they might have weird concepts you have to use, or are constantly tripping you up with namespaces, or make it really hard to write xpath queries.

> or are constantly tripping you up with namespaces You mean requires that you understand the XML format you are working with? Oh noes! Namespaces exist, just about everywhere in the world of programming, and they do so for a reason. is not the same as just like http://bar.com is not the same as http://bar.foo.com . If that's putting the bar high, I really think I may be suffering a huge disconnect from the rest of m…

The reason why many developers hate XML namespaces isn't the concept but the implementations which force you to repeat yourself everywhere. I think a significant amount of the grumbling would go away if XPath parsers were smart enough to assume that //tag was the same as //default-and-only-namespace:tag, or at least allowed you to use //name:tag instead of //{URI}tag because then you could write against the document as it exists rather than mentally having to translate names everywhere.

Yes, you can write code to add default namespaces when the document author didn't include them and pass in namespace maps everywhere but that's a lot of tedious boilerplate which requires regular updating as URLs change. Over time, people sour on that.

It really makes me wonder what it'd be like now if anyone had made an effort to invest in making the common XML tools more usable and other maintenance so e.g. you could actually rely on using XPath 2+.

Re: JSON Feed

#208
post #174

Earlier quoted context omitted.

HTTP 301 Moved Permanently is the out of band control channel. Sometimes it even seems to work, depending on software of course. There was also a typical Dave-Wineresque invention of replacing the old feed with some special, non-namespaced XML with the redirect: http://www.rssboard.org/redirect-rss-feed But of course the real problem is social. As in people simply stop blogging or stop caring. And of course tool deve…

> HTTP 301 Moved Permanently is the out of band control channel. True, but requires you to be able to set response codes on the server. I can't make my Github Pages site, or my Tumblr blog, or my S3 bucket, emit a 301. And those are the sorts of things that RSS was designed for: static sites that can't just, say, tell their backend to email people on update. You'd think that, knowing that, RSS et al would have been d…

http://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-r...

Re: JSON Feed

#209

I have grave concerns that this publishing format is delivered to us by two people that, as far as I can see, have limited to zero publishing background. That said, they're being responsive to questions in Issues, so I remain optimistic.

Learning about the history of RSS should alleviate your concerns. Brent Simmons has been working in the space for 15 years, writing one of the more popular clients and working at a company which provided sync and syndication services:

https://en.wikipedia.org/wiki/NetNewsWire#History

Re: JSON Feed

#210

Earlier quoted context omitted.

Surely there's an xml->json converter somewhere.

It's kind of tough to convert XML directly to other formats (including, but not limited to, JSON), because there are a lot of XML features that don't map cleanly onto JSON, such as: • Text nodes (especially whitespace text nodes) • Comments • Attributes vs. child nodes • Ordering of child nodes

As it happens, XSLT 3.0 and XPath 3.0 both have well documented and stable features for doing exactly this. Roundtripping XML to JSON and back is a solved problem - check it out some time; it may surprise you.
Post reply on HN