简体   繁体   English

如何从URL获取JSON作为字符串?

[英]How to get json as a string from a url?

I want to have an array with the value of json: 我想要一个具有json值的数组:

arr[ ] array = {"http://www.ip-api.com/json"};

when I print this array, how can I have json but not " http://www.ip-api.com/json " as a string? 当我打印此数组时,如何将json而不是“ http://www.ip-api.com/json ”作为字符串?

Use a JSON generating library such as Jackson and have it serialize the data structure. 使用JSON生成库(例如Jackson),并使其序列化数据结构。

https://github.com/FasterXML/jackson https://github.com/FasterXML/jackson

If you want to actually mean that you want to call the service at that URL then you need to use a suitable library for that... 如果您实际上要在该URL上调用服务,则需要为此使用合适的库...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM