Searching We.Love.Privacy.Club

Twts matching #json
Sort by: Newest, Oldest, Most Relevant

Datatypes:Go 輕鬆支持數據庫 JSON 類型
GORM 是 Go 語言中最流行的 ORM 之一,它簡化了數據庫操作,提升了開發效率。然而,在某些情況下,標準的數據類型無法滿足複雜業務需求。例如,如何將 Go 中的結構體、切片、JSON 等類型映射到數據庫字段?如何方便地進行序列化和反序列化?爲了解決這些問題,GORM 提供了 datatypes (gorm.io/datatypes) 擴展庫,旨在簡化 Go 語言中複雜數據類型與數據庫字段之間 ⌘ Read more

⤋ Read More

Go 1-24 的 omitzero:JSON 處理的福音
使用 omitempty 忽略 JSON 中的可選字段 (Go 1.24 之前)——————————————當你有一個要轉換爲 JSON 的結構體時,你可能有一些字段是可選的。例如,我們採用以下結構體:type Response struct { ID        string    json:“id” // 其他字段省略 UpdatedA ⌘ Read more

⤋ Read More
⤋ Read More

For the time being… I’ve just blocked all of OpenAI(s) Bots. They (thankfully) publish a JSON endpoint that you can use to block all OpenAI …
For the time being… I’ve just blocked all of OpenAI(s) Bots. They ( thankfully) publish a JSON endpoint that you can use to block all OpenAI crawlers from reaching your server ( in my case, blocking it at the edge). Example:

proxy-1:~# curl -qs https://openai.com/gptbot.json | jq -r '.prefixes[].ipv4Prefix' | xargs -I{} ./block-ip.sh {}

Where … ⌘ Read more

⤋ Read More
In-reply-to » For Example:

@prologic@twtxt.net maybe you meant to specify twtxt as a type similar to ActivityPub’s application/activity+json in https://webfinger.net/lookup/?resource=sorenpeter@norrebro.space

    {
      "rel": "self",
      "type": "application/activity+json",
      "href": "https://norrebro.space/users/sorenpeter"
    },

Then it would also make sense to define a Link Relations but should that then link to something like https://twtxt.dev/webfinger.html where we can describe the spec?

⤋ Read More

golang 批量執行任務的通用模板
需求一個接口調用時,接收到一個列表,十個元素,需要併發執行十個任務,每個任務都要返回執行的結果和異常,然後對返回的結果裝填到一個切片列表裏,統一返回結果。需要協程處理的結構體type Order struct { Name string json:“name” Id int json:“id” }確定通道數量一般按入參的需要處理的元素數量爲準taskNum := 10 初始化通道or ⌘ Read more

⤋ Read More

Gin 框架 JSON 格式返回結果的使用方式
大家好,我是 frank。「Golang 語言開發棧」公衆號作者。01 介紹Gin 框架爲 JSON、XML 和 HTML 渲染提供了易用的 API。本文我們主要介紹 JSON 的使用方式。02 JSON在 Go 項目開發中,當開發 HTTP API 時,我們通常提供 JSON 格式的返回結果。Go 框架爲 JSON 渲染提供了易用的 API。普通 JSON示例代碼:func main() { ⌘ Read more

⤋ Read More

爲 Nintendo Switch™ 編譯 Go 程序
之前,我們將 Go 程序編譯爲 WebAssembly,然後轉換爲 C++ 文件以在 Nintendo Switch 上運行。現在,我已成功將 Go 程序編譯爲 Nintendo Switch 的原生二進制文件,並在那裏運行遊戲。我使用-overlay選項用 C 函數調用替換系統調用。此外,我開發了一個新的包 Hitsumabushi[2] 來生成此內容的 JSON。注意–本文及文中的開源項目僅 ⌘ Read more

⤋ Read More

使用 go-jsonstruct 快速生成 Go 結構體,支持 JSON 或 YAML!
在 Go 語言開發中,我們經常需要處理 JSON 或 YAML 格式的數據。爲了方便地解析和操作這些數據,通常會定義相應的 Go 結構體與之對應。然而,手動編寫這些結構體定義可能會非常繁瑣,尤其是在處理複雜數據結構時。go-jsonstruct 工具應運而生!它可以幫助我們自動生成 Go 結構體定義,從而節省時間和精力,提高開發效率。本文將深入探討 go-jsonstruct 的功能、使用方法以及 ⌘ Read more

⤋ Read More

使用 Go 構建 Web 應用:MVC 模式、Gin 框架、GORM 和 JWT
在本文中,我們將使用 Go 編程語言構建一個 Web 應用程序,利用 Gin 框架進行路由,GORM 進行數據庫交互,並使用 JWT(JSON Web Tokens)進行身份驗證。應用程序將採用 MVC(模型 - 視圖 - 控制器)設計模式,以促進關注點的清晰分離。前置條件—-在開始之前,請確保您具備以下條件:已在您的計算機上安裝 Go(版本 1.16 或更高)。 已設置 Postgre ⌘ Read more

⤋ Read More

[ANN] If you run the haveno.markets website, please contact me

[..] Do you operate haveno.markets? You are welcome to stay pseudoanonymous but please open source the project and start accepting contributions from the community (like me). Two updates I can think of right away are to include a json api and to source data from bisq too. Please contact me at www.ki9.us/contact if you know anything about haveno.markets or its operator. If I don’t hear back after a week or two, I will have to assume haveno.markets is untrustworthy until pro … ⌘ Read more

⤋ Read More
In-reply-to » New post (mostly follow-up on the previous with a few new points) on the twtxt v2 discussion. http://a.9srv.net/b/2024-10-08

@2024-10-08T19:36:38-07:00@a.9srv.net Thanks for the followup. I agrees with most of it - especially:

Please nobody suggest sticking the content type in more metadata. 🙄

Yes, URL can be considered ugly, but they work and are understandable by both humans and machines. And its trivial for any client to hide the URLs used as reference in replies/treading.

Webfinger can be an add-on to help lookup people, and it can be made independent of the nick by just serving the same json regardless of the nick as people do with static sites and a as I implemented it on darch.dk (wf endpoint). Try RANDOMSTRING@darch.dk on http://darch.dk/wf-lookup.php (wf lookup) or RANDOMSTRING@garrido.io on https://webfinger.net

⤋ Read More
In-reply-to » (#j63urka) (#2024-09-24T12:45:54Z) @prologic I'm not really buying this one about readability. It's easy to recognize that this is a URL and a date, so you skim over it like you would we mentions and markdown links and images. If you are not suppose to read the raw file, then we might a well jam everything into JSON like mastodon

No, json is overhead. I love twtxt for simplicity where blog is just text file and not several json files where fields are repeated…

⤋ Read More

Go 熱重載:使用 Air 改變你的開發流程
在 Go 語言開發中,每次修改代碼後都需要手動重啓服務,這無疑是一件效率低下的事情。本文將介紹一款名爲 Air 的工具,它可以幫助我們實現 Go 代碼的熱重載,從而極大地提升開發效率。手動重啓的煩惱——-假設我們有一個運行中的 Go 程序,例如:go run main.go該程序可能使用 fsnotify 來監聽配置文件的變化,例如 config.json:{  ”dbhost”: ”lo ⌘ Read more

⤋ Read More

Viper:強大的 Go 配置解析庫
1 介紹Viper (https://github.com/spf13/viper) 是適用於 Go 應用程序的完整配置解決方案。它被設計用於在應用程序中工作,並且可以處理所有類型的配置需求和格式。目前 Star 26.6k, 它支持以下特性:設置默認值 從 JSON、TOML、YAML、HCL、envfile 和 Java properties 格式的配置文件讀取配置信息 實時監控和 ⌘ Read more

⤋ Read More

在 Go 中如何使用反射實現簡易版 encoding-json
在使用 Go 語言開發過程中,我們經常需要實現結構體到 JSON 字符串的序列化(Marshalling)或 JSON 字符串到結構體的反序列化(Unmarshalling)操作。Go 爲我們提供了 encoding/json 庫可以很方便的實現這一需求。在本文中,我們將探索如何使用 Go 的反射機制自己來實現一個簡易版的 encoding/json 庫。這個過程不僅能幫助我們理解序列化和反序列化 ⌘ Read more

⤋ Read More

理解並使用 Golang 的 “omitempty” 特性
在使用 Go (Golang) 並將數據編碼爲 JSON 時,您可能會遇到這樣的情況:如果某些字段的值爲空,則需要從編碼輸出中省略這些字段。這就是 Golang 的 omitempty 功能發揮作用的地方。struct 字段標記中的 omitempty 選項會告訴編碼器,如果字段爲空值,則跳過該字段。什麼是  “Empty Value”?在 Go 中,Empty Value 的定義是:布爾類型爲 ⌘ Read more

⤋ Read More

Execute commands by sending JSON? Learn how unsafe deserialization vulnerabilities work in Ruby projects
Can an attacker execute arbitrary commands on a remote server just by sending JSON? Yes, if the running code contains unsafe deserialization vulnerabilities. But how is that possible? In this blog post, we’ll describe how unsafe deserialization vulnerabilities work and how you can detect them in Ruby projects.

The post [Execute c … ⌘ Read more

⤋ Read More

yq:基於 Go 實現處理 YAML、JSON、XML、CSV、TOML 的命令行工具
在現代開發和運維的世界中,處理和轉換不同格式的數據文件如 YAML、JSON、XML、CSV 等是日常任務。文件格式的多樣性和複雜性常常給開發者帶來不小的挑戰。在這種情況下,強大的命令行工具能夠極大地簡化工作流程。本文將深入探討一個強大的多功能工具——go yq,它能夠便捷地處理 YAML、JSON、XML、CSV、TOML 以及屬性文件。安裝 go yq——–首先,我們需要安裝 go ⌘ Read more

⤋ Read More

Golang 中 JSON 操作的 5 個常見陷阱(建議收藏!)
JSON 是許多開發人員在工作中經常使用的一種數據格式。它一般用於配置文件或網絡數據傳輸等場景。由於其簡單、易懂、可讀性好,JSON 已成爲整個 IT 界最常用的格式之一。對於這種情況,Golang 和許多其他語言一樣,也提供了標準庫級別的支持, encoding/json[1]。就像 JSON 本身很容易理解一樣,用於操作 JSON 的編碼 / JSON 庫也非常容易使用。但我相信,很多開發者可 ⌘ Read more

⤋ Read More

gojq:現代 Golang JSON 查詢神器
隨着現代應用程序對數據處理和解析需求的不斷增加,JSON 已成爲數據交換的主要格式之一。在 Golang 生態系統中,解析和操作 JSON 數據的工具層出不窮,而 gojq 則是其中一款功能強大且易於使用的 JSON 查詢工具。本文將深入解析 gojq,展示其強大功能和實際應用場景,並通過豐富的示例幫助讀者全面掌握這款利器。什麼是 gojq?———gojq 是一個用 Go 語言編寫的 ⌘ Read more

⤋ Read More

在 Go 語言中,這樣使用 Json 的
Encode將一個對象編碼成JSON數據,接受一個interface{}對象,返回[]byte和error:func Marshal(v interface{}) ([]byte, error)Marshal函數將會遞歸遍歷整個對象,依次按成員類型對這個對象進行編碼,類型轉換規則如下:bool類型 轉換爲JSON的Boolean 整數,浮點數等數值類型 轉換爲JSON的Number s ⌘ Read more

⤋ Read More

利用 Go 操控 Etcd:構建強一致性系統的祕訣
etcd 是一個開源的、高可用的分佈式鍵值(key-value)存儲系統,它主要用來共享配置和服務發現。etcd 由 CoreOS 團隊開發,是以 Go 語言編寫的。etcd 採用了 Raft 協議來處理日誌複製以提供強一致性和高可用性,它成爲很多分佈式系統和雲原生技術(如 Kubernetes)中的基礎組件。etcd 的核心特性包括:簡潔的鍵值存儲:etcd 提供 HTTP/JSON API,允 ⌘ Read more

⤋ Read More
In-reply-to » (#gxolr6a) > I think @abucci and @stigatle are running snac? I didn’t have a closer look at snac (no intention of running it), but if that is a relatively small daemon (maybe comparable to Yarn?) that gives you access to the whole world of ActivityPub, then, well, yeah … That’s tough to beat.

@bender@twtxt.net I have nothing against GoToSocial, but:

GoToSocial stores statuses, accounts, etc, in a database. This can be either SQLite or Postgres.

snac is simpler. Some JSON files and that’s it. I can read them with jq and less. I can use tar to back them up. I can hand edit them in a text editor.

⤋ Read More

I think @abucci@anthony.buc.ci and @stigatle@yarn.stigatle.no are running snac? I didn’t have a closer look at snac (no intention of running it), but if that is a relatively small daemon (maybe comparable to Yarn?) that gives you access to the whole world of ActivityPub, then, well, yeah … That’s tough to beat.

Yes, I am running snac on the same VPS where I run my yarn pod. I heard of it from @stigatle@yarn.stigatle.no, so blame him 😏 snac is written in C and is one simple executable, uses very little resources on the server, and stores everything in JSON files (no databases or other integrations; easy to save and migrate your data) . It’s definitely like yarn in that respect.

I haven’t been around yarn much lately. Part of that is that I’ve been very busy at work and home and only have a limited time to spend goofing off on a social network. Part of it is that I’m finding snac very useful: I’ve connected with friends I’d previously lost touch with, I’ve found useful work-related information, I’ve found colleagues to follow, and even found interesting conferences to attend. There’s a lot more going on over there.

I guess if I had to put it simply, I’d say I have limited time to play and there are more kids in the ActivityPub sandbox than this one. That’s not a ding on yarn–I like yarn and twtxt–I’m just time constrained.

⤋ Read More

Golang 如何動態解析 JSON
Go 以其簡潔高效而聞名,提供了強大的工具用於處理 JSON 數據。雖然基於結構體的解析很常見,但在某些情況下,JSON 結構是動態的或未知的。在本文章中,我們將探討如何使用 Go 語言中的空接口進行動態 JSON 解析,從而實現靈活性,無需預定義結構體。什麼是 Dynamic JSON Parsing動態 JSON 解析指的是能夠處理具有不同結構的 JSON 數據,適應不同模式而無需嚴格定義。在 ⌘ Read more

⤋ Read More

使用 mapstructure 高效解析 Go 語言中的動態數據結構
在處理數據流(如 JSON、Gob 等)過程中,我們可能不知道底層數據的結構,這時mapstructure庫就能大顯身手了。這款 Go 語言庫可以將通用 map 值解碼爲 Go 本地結構,也可執行反向操作,並提供有用的錯誤處理功能。今天,我們就深入瞭解這個庫,並列舉一些豐富的示例來幫助你掌握它的使用方法。簡介–mapstructure是一款 Go 庫,允許開發者將map[string]inter ⌘ Read more

⤋ Read More

Go Gin 框架的模型綁定與驗證詳解
在 Web 開發中,模型綁定和驗證是確保數據完整性和減少安全風險的重要步驟。Go 語言的 Gin 框架提供了強大而靈活的模型綁定和驗證機制,本文將深入講解 Gin 框架中如何進行模型綁定和驗證,以及如何自定義驗證器。在 Gin 框架中,模型綁定通常指將請求的數據(例如 JSON、表單數據)綁定到指定的結構體上,而驗證則是確保綁定後的數據符合我們設置的規則。Gin 框架使用binding標籤來實現模 ⌘ Read more

⤋ Read More

使用 Gin 框架中的 PureJSON 發送未轉義的 JSON
當我們使用 Go 的 Gin web 框架來構建 RESTful API 時,通常會遇到返回 JSON 響應的需求。Gin 框架提供了c.JSON方法來以 JSON 格式發送回覆,同時它會對特殊字符進行轉義,比如把 < 轉換爲 \u003c。但在某些情況下,我們需要發送未轉義的 JSON 數據,這時我們就可以使用 Gin 框架中的c.PureJSON方法。在 Gin 框架中,c.PureJSON方 ⌘ Read more

⤋ Read More

使用 Go Gin SecureJSON 技術保護你的 JSON 數據
網絡上的安全問題一直是不能小覷的難題,尤其在 web 開發中,JSON 劫持就是其中的一種。這篇文章,我們將聚焦在 Go 框架 Gin 下的 SecureJSON 使用,來保護我們的 JSON 數據。什麼是 JSON 劫持?————JSON 劫持是一種網絡攻擊手段,攻擊者利用 JavaScript 的這個特性獲取到不屬於自己的數據。由於 JSON 數據一般包含非常敏感的個人信息,例 ⌘ Read more

⤋ Read More

Gob 實踐全攻略,數據傳輸利器
*1. Gob 簡介1.1 Gob 概述Gob(Go binary)是 Go 語言中用於序列化和反序列化數據的編碼庫。它是 Go 語言的標準庫之一,專門設計用於在 Go 程序之間高效地傳輸數據。Gob 可以將複雜的數據結構編碼成二進制格式,便於在不同系統之間傳遞,並支持版本控制和演進。1.2 爲什麼選擇 GobGob 相比其他序列化格式(如 JSON、XML)具有更高的性能和更小的數據體積。它是專 ⌘ Read more

⤋ Read More

Go: XML 文件的讀寫操作詳解
*概述XML(可擴展標記語言)作爲一種常見的數據交換格式,廣泛應用於配置文件、數據傳輸等場景。本文將介紹如何在 Go 語言 中進行 XML 文件的讀寫操作,涵蓋 XML 基礎知識、編碼 / 解碼基礎、讀取 XML 文件、寫入 XML 文件、實戰操作示例以及 XML 與 JSON 對比選型。一、XML 基礎知識簡介XML 語法結構XML 採用標籤(tag)來標記數據,具有自我描述性。一個基本的 XM ⌘ Read more

⤋ Read More

Go JSON 文件讀寫最佳實踐
*概述在 Go 語言中,JSON(JavaScript Object Notation)是一種常見的數據交換格式,用於在不同語言之間進行數據傳遞。本文將介紹 Go 語言中如何進行 JSON 文件的讀寫操作,包括解析與序列化,錯誤處理,以及一些實用技巧。一、JSON 文件基礎操作JSON 文件的讀取如何從 JSON 文件中讀取數據。package mainimport ( “encoding/js ⌘ Read more

⤋ Read More

I’m not super a fan of using json. I feel we could still use text as the medium. Maybe a modified version to fix any weakness.

What if instead of signing each twt individually we generated a merkle tree using the twt hashes? Then a signature of the root hash. This would ensure the full stream of twts are intact with a minimal overhead. With the added bonus of helping clients identify missing twts when syncing/gossiping.

Have two endpoints. One as the webfinger to link profile details and avatar like you posted. And the signature for the merkleroot twt. And the other a pageable stream of twts. Or individual twts/merkle branch to incrementally access twt feeds.

⤋ Read More

PEP 710: Recording the provenance of installed packages
This PEP describes a way to record the provenance of installed Python distributions. The record is created by an installer and is available to users in the form of a JSON file provenance_url.json in the .dist-info directory. The mentioned JSON file captures additional metadata to allow recording a URL to a :term:`distribution package` together with the installed distribution hash. This proposal is built on top of PEP 610 following :ref:`its corresponding canonical PyPA spec … ⌘ Read more`

⤋ Read More
In-reply-to » Trying to wrap my head around webfinger..

so in effect it would look something like this:

---
subject: acct:me@sour.is
aliases:
  - salty:me@sour.is
  - yarn:xuu@ev.sour.is
  - status:xuu@chaos.social
  - mailto:me@sour.is
---
subject: salty:me@sour.is
aliases:
  - acct:me@sour.is
links:
  - rel:    self
    type:   application/json+salty
    href:   https://ev.sour.is/inbox/01GAEMKXYJ4857JQP1MJGD61Z5
    properties:
        "http://salty.im/ns/nick":    xuu
        "http://salty.im/ns/display": Jon Lundy
        "http://salty.im/ns/pubkey":     kex140fwaena9t0mrgnjeare5zuknmmvl0vc7agqy5yr938vusxfh9ys34vd2p
---
subject: yarn:xuu@ev.sour.is
links:
  - rel: https://txt.sour.is/user/xuu
    properties:
        "https://sour.is/rel/redirect": https://txt.sour.is/.well-known/webfinger?resource=acct%3Axuu%40txt.sour.is
---    
subject: status:xuu@chaos.social
links:
   - rel: http://joinmastodon.org#xuu%40chaos.social
     properties:
        "https://sour.is/rel/redirect": https://chaos.social/.well-known/webfinger?resource=acct%3Axuu%40chaos.social
---
subject: mailto:me@sour.is
...

⤋ Read More
In-reply-to » Trying to wrap my head around webfinger..

@prologic@twtxt.net That was exactly my thought at first too. but what do we put as the rel for salty account? since it is decentralized we dont have a set URL for machines to key off. so for example take the standard response from okta:

# http GET https://example.okta.com/.well-known/webfinger  resource==acct:bob
{
    "links": [
        {
            "href": "https://example.okta.com/sso/idps/OKTA?login_hint=bob#",
            "properties": {
                "okta:idp:type": "OKTA"
            },
            "rel": "http://openid.net/specs/connect/1.0/issuer",
            "titles": {
                "und": "example"
            }
        }
    ],
    "subject": "acct:bob"
}

It gives one link that follows the OpenID login. So the details are specific to the subject acct:bob.

Mastodons response:

{
  "subject": "acct:xuu@chaos.social",
  "aliases": [
    "https://chaos.social/@xuu",
    "https://chaos.social/users/xuu"
  ],
  "links": [
    {
      "rel": "http://webfinger.net/rel/profile-page",
      "type": "text/html",
      "href": "https://chaos.social/@xuu"
    },
    {
      "rel": "self",
      "type": "application/activity+json",
      "href": "https://chaos.social/users/xuu"
    },
    {
      "rel": "http://ostatus.org/schema/1.0/subscribe"
    }
  ]
}

it supplies a profile page and a self which are both specific to that account.

⤋ Read More